Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Took a bit of fiddling to get from those links to exactly what I wanted but here it is. (Most of the difficulty was getting it to work in Mingw32.)</p> <pre><code>// -*- compile-command:"g++ mem.cpp -lpsapi -g -o mem.exe"; -*- // Shows the memory: private bytes, working set and virtual size for a process #include &lt;windows.h&gt; #include &lt;stdio.h&gt; #include &lt;psapi.h&gt; // MingW32 doesn't have this struct in psapi.h typedef struct _PROCESS_MEMORY_COUNTERS_EX { DWORD cb; DWORD PageFaultCount; SIZE_T PeakWorkingSetSize; SIZE_T WorkingSetSize; SIZE_T QuotaPeakPagedPoolUsage; SIZE_T QuotaPagedPoolUsage; SIZE_T QuotaPeakNonPagedPoolUsage; SIZE_T QuotaNonPagedPoolUsage; SIZE_T PagefileUsage; SIZE_T PeakPagefileUsage; SIZE_T PrivateUsage; }PROCESS_MEMORY_COUNTERS_EX, *PPROCESS_MEMORY_COUNTERS_EX; void PrintMemoryInfo( DWORD processID ) { HANDLE hProcess; PROCESS_MEMORY_COUNTERS_EX pmc; // Print the process identifier. printf( "\nProcess ID: %u\n", processID ); // Print information about the memory usage of the process. hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID ); if (NULL == hProcess) return; if ( GetProcessMemoryInfo( hProcess, (PROCESS_MEMORY_COUNTERS *) &amp;pmc, sizeof(pmc)) ) { printf( "\tWorkingSetSize: %u\n", pmc.WorkingSetSize ); printf( "\tPrivate Bytes: %u\n", pmc.PrivateUsage ); printf( "\tPagefile (peak): %u (%u)\n", pmc.PagefileUsage, pmc.PeakPagefileUsage ); } CloseHandle( hProcess ); } int main() { DWORD id = GetCurrentProcessId(); PrintMemoryInfo(id); return 0; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload