Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Process.PrivateMemorySize64 /1024 not match what Windows Task Manager Memory (Private Working Set)?

Why does Process.PrivateMemorySize64 /1024 not match what Windows Task Manager Memory (Private Working Set)?

There seems to be a big (~ 30%) difference. Plus the value doesn't update frequently like task manager.

Calling _process.Refresh() doesn't help.

like image 947
CodingHero Avatar asked Oct 23 '14 09:10

CodingHero


2 Answers

You are looking at different things.

The PrivateMemorySize64 property from the Process class is the equivalent of the Private Bytes performance counter. It represents the total amount of private memory allocated for the associated process that cannot be shared with other processes. Private bytes are not only physical memory, but also paged files etc.

On the other end the Private Working Set tracks a subset of the private bytes above, which represents only the physical memory that a process is using and can't be shared with other processes.

like image 179
Faris Zacina Avatar answered Oct 27 '22 00:10

Faris Zacina


The PrivateMemorySize64 represents all your private memory, not just the private working set, which is the amount of private memory that is currently not paged to disk.

In case you would like to know the total size of your process, you should use the VirtualMemorySize64 property instead. It accounts for all memory allocated by your process regardless of whether that memory is paged or on RAM. This is useful for example to know if your 32 bit process is getting close to 2GB of Virtual Size (process address space), which is normally the limit for a 32 bit process (unless one uses the /3GB option on a 32 bit Windows or the application runs on a 64 bit version of Windows and is large address aware).

like image 38
Gui Avatar answered Oct 26 '22 23:10

Gui