Why does any value from Process Memory Counter is not similar to the memory used value shown in the task manager?

656 Views Asked by At

Process Memory Counter is defined structure available in the psapi (Process Status API). Its structure is defined as,

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;

I use GetProcessMemoryInfo method which has the syntax, BOOL GetProcessMemoryInfo(HANDLE Process, PROCESS_MEMORY_COUNTERS* pmc,DWORD size_pmc);

From the struct variable pointer pmc I can access the WorkingSetSize of a process (say mspaint.exe) as pmc.WorkingSetSize.

But the memory value displayed in the task manager is not the same as any of the values in the structre. My Questions are,

  1. What are these values?
  2. What is the value displayed in the task manager?
  3. What is the programmatic way to get the memory used as displayed in the task manager?
  4. Can it be calculated using the process memory counter itself?

PS: The preferred language is C++ and I want to do it without running any commands in the command prompt.

0

There are 0 best solutions below