2
votes

I've found several answers to this question here on SO, but none that answers my question. I'm trying to track down some memory leaks in our unmanaged C++ application, and from reading the following, it seems that "Memory - Commit Size" is the best metric to use when monitoring memory usage: http://forum.sysinternals.com/virtual-private-bytes-and-working-set_topic18296.html

Here's the explanation of the various metrics reported by Windows Task Manager: http://windows.microsoft.com/en-us/windows-vista/what-do-the-task-manager-memory-columns-mean

I've found the following that describes how to retrieve the Working Set data for a named process: http://msdn.microsoft.com/en-us/library/76yt3c0w.aspx

System.Diagnostics.Process[] processes =
    System.Diagnostics.Process.GetProcessesByName(theprocessName);
System.Diagnostics.Process process = processes[0];

However, this mentions nothing about Committed Memory:

Can anyone help? Paul

1
Note that I updated the tags to include C++ and winapi as these are key to categorizing your question, more so than "memory" and "leak". - Jonathon Reinhart

1 Answers

4
votes

It looks like you want to use GetProcessMemoryInfo. This populates a PROCESS_MEMORY_COUNTERS structure.

The key element of this structure you'll be interested in is

PagefileUsage The Commit Charge value in bytes for this process. Commit Charge is the total amount of memory that the memory manager has committed for a running process.