Possible Duplicate:
How to get memory available or used in C#
I want to visualize the memory which is used by my application in the statusbar of my application. I am searching for a memoryleak - but I don't know where. Now, my idea is to visualize the used memory in the statusbar so that I can see it while I am working with the application and find the part, where the problem occurs and then I can profiling this.
Can someone give me some help, how can I get the used memory.
If you really want to know what amount of memory your application actually uses, you need to run it within a profiler. For example, Valgrind can give you insights about the amount of memory used, and, more importantly, about possible memory leaks in your program. The heap profiler tool of Valgrind is called 'massif':
Another option to monitor CPU usage on RT targets is to use the Real-Time Trace Viewer. With the Real-Time Trace Viewer, you can create execution traces that allow you view memory allocation, CPU usage, and thread scheduling.
The limit is 16 MB on very old devices, 24 MB or 32 MB on newer ones.
You can use the following function (The true parameter tells the GC to perform a collection first):
long memory = GC.GetTotalMemory(true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With