Why does Process.PrivateMemorySize64 / 1024 not match that memory of the Windows Task Manager (Private Working Set)?

Why Process.PrivateMemorySize64 /1024 not match that memory of the Windows Task Manager (Private Working Set)?

There seems to be a big (~ 30%) difference. In addition, the value is often not updated as a task manager.

Calling _process.Refresh() does not help.

+5
source share
2 answers

You look at different things.

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

At the other end, the Private Working Set keeps track of a subset of the private bytes above, which represents only the physical memory that this process uses and cannot be transferred to other processes.

+4
source

PrivateMemorySize64 represents your personal memory, not just a private working set, which is the amount of private memory that is not currently being uploaded to disk.

If you want to know the total size of your process, you should use the VirtualMemorySize64 property. It takes into account all the memory allocated by your process, regardless of whether this memory is loaded or in RAM. This is useful, for example, to find out if your 32-bit process is approaching 2 GB of virtual size (process address space), which is usually the limit for a 32-bit process (unless you use the / 3GB option on a 32-bit Windows or an application runs on a 64-bit version of Windows and has a large address).

+1
source

Source: https://habr.com/ru/post/1205345/


All Articles