Windows Server task manager displays much higher memory use than sum of all processes’ working set size

memory usagesql-server-2008virtual-memorywindows-server-2008

I have a 16 GB Windows Server 2008 x64 machine mostly running SQL Server 2008. The free memory as seen in Task Manager is very low (128 MB at the moment), i.e. about 15.7 GB are used. So far, so good.

Now when I try to narrow down the process(es) using the most memory I get confused: None of the processes have more than 200MB Working Set Size as displayed in the 'Processes' tab of Task Manager. Well, maybe the Working Set Size isn't the relevant counter?

To figure that out I used a PowerShell command [1] to sum up each individual property of the process object in sort of a brute force approach – surely one of them must add up to the 15.7 GB, right? Turns out none of them does, with the closest being VirtualMemorySize (around 12.7 GB) and PeakVirtualMemorySize (around 14.7 GB). WTF?

To put it another way: Which of the numerous memory related process information is the "correct" one, i.e. counts towards the server's physical memory as displayed in the Task Manager's 'Performance' tab?

Thank you all!

[1] $erroractionpreference="silentlycontinue"; get-process | gm | where-object {$.membertype -eq "Property"} | foreach-object {$.name; (get-process | measure-object -sum $_.name ).sum / 1MB}

Best Answer

Adding up the memory usage of all processes will not generally produce meaningful results. That will leave two major users of memory unaccounted for, the system cache and the standby list. You cannot account for memory usage by simply adding up a list of numbers. The memory management system is far too complex for that.