Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the amount of memory used by an application [duplicate]

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.

like image 571
BennoDual Avatar asked Dec 25 '12 17:12

BennoDual


People also ask

How do I measure application memory usage?

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':

What will you use to monitor the amount of memory being used by the application in real time?

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.

How much memory should an application use?

The limit is 16 MB on very old devices, 24 MB or 32 MB on newer ones.


1 Answers

You can use the following function (The true parameter tells the GC to perform a collection first):

long memory = GC.GetTotalMemory(true); 
like image 65
geniaz1 Avatar answered Oct 06 '22 09:10

geniaz1