0

So I use Process.GetProcesses() (from System.Diagnostics) to get all of my processes. I then try to sum up the total memory of each process to compare it to what Windows Task Manager is reporting in the 'Physical Memory Usage History' section of the Performance tab. I've tried all the memory types available and none add up. I expected it to be working set, but that still leaves about a 1GB gap.

So does GetProcesses not return all of the processes, is there a different way to use the Process class to get the actual memory as reported by Task Manager on the Performance tab, or is the Process class unable to be used to get the same memory usage report?

(I've seen How to calculate memory usage as Task Manager does?, but I'm looking to do it with the Process class.)

Community
  • 1
  • 1
Lawtonfogle
  • 974
  • 4
  • 17
  • 32
  • If you read the documentation: *"Multiple Windows services can be loaded within the same instance of the Service Host process (svchost.exe). GetProcesses does not identify those individual services; for that, see GetServices."* That may be where some of your discontinuity lies. – Ron Beyer Jul 29 '15 at 15:49
  • Memory management in Windows is a *lot* more intricate than you assume. Not a decent subject for a Q+A site, books have been written about it. Windows Internals is best. – Hans Passant Jul 29 '15 at 16:07
  • @RonBeyer Even if the multiple services are in an instance of svchost.exe, when I look at svchost's workingset64 shouldn't I see the combined memory use? – Lawtonfogle Jul 29 '15 at 18:15
  • @HansPassant I'm not asking about the general memory operation, but only how to pull the same report. Consider how someone may ask how to do reflection to get a private variable or to optimize a SQL statement using an index. Both of those are complex topics involving books of material, but the specific questions are still valid for a site like this. – Lawtonfogle Jul 29 '15 at 18:18

0 Answers0