Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process Memory Size - Different Counters

I'm trying to find out how much memory my own .Net server process is using (for monitoring and logging purposes).

I'm using:

Process.GetCurrentProcess().PrivateMemorySize64

However, the Process object has several different properties that let me read the memory space used: Paged, NonPaged, PagedSystem, NonPagedSystem, Private, Virtual, WorkingSet

and then the "peaks": which i'm guessing just store the maximum values these last ones ever took.

Reading through the MSDN definition of each property hasn't proved too helpful for me. I have to admit my knowledge regarding how memory is managed (as far as paging and virtual goes) is very limited.

So my question is obviously "which one should I use?", and I know the answer is "it depends".

This process will basically hold a bunch of lists in memory of things that are going on, while other processes communicate with it and query it for stuff. I'm expecting the server where this will run on to require lots of RAM, and so i'm querying this data over time to be able to estimate RAM requirements when compared to the sizes of the lists it keeps inside.

So... Which one should I use and why?

like image 506
Daniel Magliola Avatar asked Aug 27 '08 20:08

Daniel Magliola


1 Answers

If you want to know how much the GC uses try:

GC.GetTotalMemory(true)

If you want to know what your process uses from Windows (VM Size column in TaskManager) try:

Process.GetCurrentProcess().PrivateMemorySize64

If you want to know what your process has in RAM (as opposed to in the pagefile) (Mem Usage column in TaskManager) try:

Process.GetCurrentProcess().WorkingSet64

See here for more explanation on the different sorts of memory.

like image 55
Lars Truijens Avatar answered Oct 01 '22 15:10

Lars Truijens