How to determine a process "virtual size" (WinXP)?
I have a program that needs a lot of memory, and it crashes as soon as the 2GB virtual address space is reached. Sysinternals process explorer displays this as "virtual size" column. How can I determine this "virtual size" with C (or C++) code?
Ok, I have to query a performance counter for "Virtual Bytes". Perfmon shows the query string (or how it is called) as, for example, 'Process(firefox)Virtuelle Größe' on my German Win XP installation.
How do I determine the query string for the 'current process', and is there a non-localized name for it?
According to MSDN: Memory Performance Information PROCESS_MEMORY_COUNTERS_EX.PrivateUsage
is the same as VM Size in Task Manager in Windows XP. GetProcessMemoryInfo should work:
PROCESS_MEMORY_COUNTERS_EX pmcx = {};
pmcx.cb = sizeof(pmcx);
GetProcessMemoryInfo(GetCurrentProcess(),
reinterpret_cast<PROCESS_MEMORY_COUNTERS*>(&pmcx), pmcx.cb);
Now pmcx.PrivateUsage
holds the VM Size of the process.
You query a performance counter.
There is a complete API for this in the win32 API, read about it here.
You can look at all the performance counters if you run a program called 'perfmon.exe'
You can use a performance counter. The Process Object has a "Virtual Bytes" value.
链接地址: http://www.djcxy.com/p/80176.html上一篇: 增加虚拟字节的操作和功能