Monitor Memory
-
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
-
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
Is there something wrong with using the Performance Monitor built into Windows? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
Is there something wrong with using the Performance Monitor built into Windows? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
Well, stress testgin will last for a quite long time , and I can't stay there stare at it whole day.
-
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
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
-
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
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.
-
Well, stress testgin will last for a quite long time , and I can't stay there stare at it whole day.
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
-
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
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.
-
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
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