We help IT Professionals succeed at work.

Find total memory used (Commit Charge) on a system in C++

sinclaj1
sinclaj1 asked
on
 We are writing some debugging code inside of a C++ API that is spawned as a COM+ object.  There are multiple instances of this object at a given time, and we are writing some code to append to a text file the date and time the program is run.  This part is done.  However, what I would like to do is to get the TOTAL (physical & VM combined) memory used at that time and write out the number of bytes being used (should be the same as the Commit Charge in the NT Task Manager window).

  A quick response would be most appreciated!  Thank you!

Comment
Watch Question

jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
Use 'GlobalMemoryStatus()' to obtain that information:

"The GlobalMemoryStatus function obtains information about the computer system's current usage of both physical and virtual memory.

VOID GlobalMemoryStatus(
  LPMEMORYSTATUS lpBuffer   // pointer to the memory status structure
);"
CERTIFIED EXPERT
Top Expert 2012
Commented:

Author

Commented:
I appreciate the quick response.  We looked all over MSDN for this...guess you just have to know how to do it!  Thanks for all your help, it works like a charm!
jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
>>We looked all over MSDN for this...guess you just have
>>to know how to do it!

Well, I'd say it's just a case of 'been there, done that..' :o)

Thanks!