C++ API to get the private and virtual bytes consumed by a process
Is there 开发者_开发百科an API provided by Microsoft to get the private and virtual bytes consumed by a process ?
GetProcessMemoryInfo could be of great use.
To complement the answer by DumbCoder which amongst others gives you physical memory usage, you should also take a look at GlobalMemoryStatusEx
.
Here you can find the definition of virtual bytes according to Microsoft and how you can derive it as a simple difference from two counters that GlobalMemoryStatusEx
provides.
Notes of caution:
- The function
GlobalMemoryStatusEx
has mixed purpose since it provides information about the system as a whole and information specific to the calling process, e.g. virtual memory usage. - Read/apply the API carefully otherwise you can end up with broken counters.
精彩评论