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

天涯浪子 提交于 2019-12-23 09:07:32

问题


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.


回答1:


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.




回答2:


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).



来源:https://stackoverflow.com/questions/26524656/why-does-process-privatememorysize64-1024-not-match-what-windows-task-manager-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!