How to determine a process “virtual size” (WinXP)?

前端 未结 6 1627
渐次进展
渐次进展 2020-12-31 12:27

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 si

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-31 13:17

    I needed the same thing as theller, but unfortunately needed it for a process other than my own. Because of this, theller's self-answer of using "MEMORYSTATUSEX.ullTotalVirtual–MEMORYSTATUSEX.ullAvailVirtual" didn't work for me, since GlobalMemoryStatusEx() (the function that returns MEMORYSTATUXEX) only works for the current process.

    So far, I've been unable to find exactly what I was looking for without using performance counters (I didn't get into those because they looked way more complex than what I was looking for). I got very close by looping around and using "VirtualQueryEx" to explore the address space of the desired process, counting up all of the regions that didn't have a State of MEM_FREE. In my tests, it seemed to be a constant 17M higher than I would have expected when comparing to Process Explorer. ...also, it is certainly not race-condition free.

    Anyway, I know this is sorta a non-answer, but I figured I'd at least document the progress I'd made on this for whoever stumbles upon this next.

提交回复
热议问题