Virtual, Private, Working set and VirtualQueryEx

Virtual, Private, Working set and VirtualQueryEx

Post by a3JldXplcm » Tue, 30 Jun 2009 16:05:01



Hi,
I'm wondering if I can retrieve virtual bytes, private bytes and working set
of a process using VirtualQueryEx()?
It seems that if I count all MEM_COMMIT and MEM_RESERVE regions I get the
virtual, but how I can get the private memory? I guess I should count all
MEM_COMMIT, but should I filter out the executable pages?

And no, I cannot use PROCESS_MEMORY_COUNTERS_EX since it is not supported on
Win2k.
 
 
 

Virtual, Private, Working set and VirtualQueryEx

Post by Pavel Lebe » Tue, 30 Jun 2009 17:33:37


Use PROCESS_MEMORY_COUNTERS.PagefileUsage. For all
user processes it is equivalent to private bytes (see the "Memory
Performance Information" topic in MSDN for more details).

VirtualQuery would be a lot more expensive, and you wouldn't be able
to account for all of private bytes this way. The closest you can get
is the sum of all committed MEM_PRIVATE regions and all copy-on-write
mapped views (data and image). The actual private bytes will be
slightly larger than that value because private bytes also include process
page table pages which live in the kernel space.

--
Pavel Lebedinsky/Windows Kernel Test
This posting is provided "AS IS" with no warranties, and confers no rights.