Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Monitor Memory

Monitor Memory

Scheduled Pinned Locked Moved C#
questioncsharpc++testingbeta-testing
8 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jinzhecheng
    wrote on last edited by
    #1

    Hi , C# Fellows, I am writting a program to deal with C++ Dll. When I do stress testing , (run the program continously), at the end I got "Out of Memory" Exception , So I am thinking of adding some code to monitor memory change. But the prolem here is , I dont know when the Garbage Collector will kick in. So , Its critical to catch this event.How Can I do it in C#--??? Thanks

    D L T A 4 Replies Last reply
    0
    • J jinzhecheng

      Hi , C# Fellows, I am writting a program to deal with C++ Dll. When I do stress testing , (run the program continously), at the end I got "Out of Memory" Exception , So I am thinking of adding some code to monitor memory change. But the prolem here is , I dont know when the Garbage Collector will kick in. So , Its critical to catch this event.How Can I do it in C#--??? Thanks

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Is there something wrong with using the Performance Monitor built into Windows? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      J 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Is there something wrong with using the Performance Monitor built into Windows? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        J Offline
        J Offline
        jinzhecheng
        wrote on last edited by
        #3

        Well, stress testgin will last for a quite long time , and I can't stay there stare at it whole day.

        D 1 Reply Last reply
        0
        • J jinzhecheng

          Hi , C# Fellows, I am writting a program to deal with C++ Dll. When I do stress testing , (run the program continously), at the end I got "Out of Memory" Exception , So I am thinking of adding some code to monitor memory change. But the prolem here is , I dont know when the Garbage Collector will kick in. So , Its critical to catch this event.How Can I do it in C#--??? Thanks

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          Some GDI+ errors give this exception, most notably destrpying a byte[] from which an image was loaded. Else use windows monitpr tools, it a has grapghs u dont have to wait. Or use Clr Profiler but it will be rather difficult to catch a issue. Are you (not) freeing memory alloc'ed for some C++ functions perhaps? xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

          A 1 Reply Last reply
          0
          • L leppie

            Some GDI+ errors give this exception, most notably destrpying a byte[] from which an image was loaded. Else use windows monitpr tools, it a has grapghs u dont have to wait. Or use Clr Profiler but it will be rather difficult to catch a issue. Are you (not) freeing memory alloc'ed for some C++ functions perhaps? xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            hi, Leppie, I make it clearer: what I want is a record something like this: time:- 8:12:21, Event : function ..called,free memory size: ..Bytes time:-8:12:23, Event : GC called ., free memory size : ..Bytes; so later on we can determine which function does have memory leak. and ,Yes , some Dll call locate memory and release later.

            1 Reply Last reply
            0
            • J jinzhecheng

              Well, stress testgin will last for a quite long time , and I can't stay there stare at it whole day.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              It can log the data to a Perofmrnace log file. But since, in your other post, you said that you want to log what looks like every function call, Performance Monitor won't help you. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              1 Reply Last reply
              0
              • J jinzhecheng

                Hi , C# Fellows, I am writting a program to deal with C++ Dll. When I do stress testing , (run the program continously), at the end I got "Out of Memory" Exception , So I am thinking of adding some code to monitor memory change. But the prolem here is , I dont know when the Garbage Collector will kick in. So , Its critical to catch this event.How Can I do it in C#--??? Thanks

                T Offline
                T Offline
                Tom Larsen
                wrote on last edited by
                #7

                Technically I don't think it is ever specified when the GC happens (no behavior in the ECMA is specified for this?) and technically you as a .Net Framework programmer shouldn't care. There is no real concept of "memory" in a virtual machine like the .Net Framework. An object holds a "reference" not a memory address. Memory is treated just like other resources (file handles, sockets, etc). The virtual machine can either allocate the resources necessary to vivify (is that the right word? :-)) the object or it fails and hopefully throws an exception that is meaningful. So from what I read you want C# code that knows when it can't create any more objects. This is inherently hard to do in a virtual machine system like the .Net Framework because all of the innards are virtual! :-) In general the .Net Framework will not tell you before hand whether you can create the object before you create it. You can gather some information about the external OS and try to make a judgement then but I haven't found a .Net Framework facility to check if it will succeed making the next object beyond trying to make the next object. ps. Since it sounds like you are dealing with a DLL written in C/C++, maybe you are leaking memory because you aren't handling allocation correctly? If you fix that you don't need to worry about trying to monitor memory usage.

                1 Reply Last reply
                0
                • J jinzhecheng

                  Hi , C# Fellows, I am writting a program to deal with C++ Dll. When I do stress testing , (run the program continously), at the end I got "Out of Memory" Exception , So I am thinking of adding some code to monitor memory change. But the prolem here is , I dont know when the Garbage Collector will kick in. So , Its critical to catch this event.How Can I do it in C#--??? Thanks

                  A Offline
                  A Offline
                  Andy Brummer
                  wrote on last edited by
                  #8

                  You can use the CLR Profiler[^] to get this type of information, or if it doesn't work for you, you can write your own profiler that ties into the .net profiler api to get that information.


                  I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups