How to get memory information (free/total/vm/etc...) of a pc [C#]

Shaitan00

Junior Contributor
Joined
Aug 11, 2003
Messages
358
Location
Hell
When the Out_Of_Memory exception is caught I want to log the systems current memory usage (not application, system), minimally free memory... Preferably also max memory, free VM and max VM, and anything else that can pin point the system state when it crashes...
Now I know how to do this in WMI or Script but I have not been able to find a way to accomplish this task in C# (2005/2.0)...
Any ideas, hints, and help would be greatly appreciated, thanks
 
The idea is - the exception is "Out Of Memory" so I want to see the memory at 0 - so I thought if I outputed the actual memory usage I would see it be 0... I just find it odd that my program, while loading the map, can max out a 128meg ram machine running XP SP2.... odd indeed...
 
Maybe you should upload some code. It sounds like you have some severe memory management issues. Perhaps you are doing lots of string processing and the garbage collector is not getting a chance to clean up all the old strings (this can, on a very large scale operation, eat a huge amount of memory), or you aren't disposing large objects, or something to that effect. If you upload all of the code in question we could analyze it and possibly identify some issues.
 
marble_eater: I have attached a full set of CLR Profiler logs to another post on a similar topic (http://www.xtremedotnettalk.com/showthread.php?p=458499#post458499), hopefully that can help in the analysis...

As for code, I am working on posting some snipplets with explanation on areas where I think I may possibly be leaking memory, etc ... - I'll follow up shortly (I need to write it out first).

Thanks for the help - much appreciated...
 
Back
Top