Parameters
Process
[in] Handle to the process. The handle must have the PROCESS_QUERY_INFORMATION and PROCESS_VM_READ access rights. For more information, see Process Security and Access Rights.
ppsmemCounters
[out] Pointer to the PROCESS_MEMORY_COUNTERS or PROCESS_MEMORY_COUNTERS_EX structure that receives information about the memory usage of the process.
cb
[in] Size of the ppsmemCounters structure, in bytes.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Example Code
For an example, see Collecting Memory Usage Information for a Process.
Requirements
Client Requires Windows XP, Windows 2000 Professional, or Windows NT Workstation 4.0.
Server Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.
Header Declared in Psapi.h.
Library Link to Psapi.lib.
DLL Requires Psapi.dll.
PROCESS_MEMORY_COUNTERS
The PROCESS_MEMORY_COUNTERS structure contains the memory statistics for a process.
typedef struct _PROCESS_MEMORY_COUNTERS { 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;
} PROCESS_MEMORY_COUNTERS, *PPROCESS_MEMORY_COUNTERS;
Members
cb
Size of the structure, in bytes.
PageFaultCount
Number of page faults.
PeakWorkingSetSize
Peak working set size, in bytes.
WorkingSetSize
Current working set size, in bytes.
QuotaPeakPagedPoolUsage
Peak paged pool usage, in bytes.
QuotaPagedPoolUsage
Current paged pool usage, in bytes.
QuotaPeakNonPagedPoolUsage
Peak nonpaged pool usage, in bytes.
QuotaNonPagedPoolUsage
Current nonpaged pool usage, in bytes.
PagefileUsage
Current space allocated for the pagefile, in bytes. Those pages may or may not be in memory.
PeakPagefileUsage
Peak space allocated for the pagefile, in bytes.
Requirements
Client Requires Windows XP, Windows 2000 Professional, or Windows NT Workstation 4.0.
Server Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.
Header Declared in Psapi.h.
Collecting Memory Usage Information For a Process
To determine the efficiency of your application, you may want to examine its memory usage. The following sample code uses the GetProcessMemoryInfo function to obtain information about the memory usage of a process.