Windows – Measure Total RAM Usage of a Program

memoryprocessprocess-explorertaskswindows

I was comparing the memory usage of different portable browsers but this question is general for all programs that open up in several sub-processes in task manager.

See the screenshot from Sysinternals Process Explorer below:

One programm opens several processes

Firefox for example just opens up in one process, while Google Chrome starts several processes for each tab.

So how can I get the total RAM usage for all processes opened by one program? (Here for Google Chrome for example.)

Of course I could just use a calculator and reckon up the sum… but there must be a more convenient way!

Best Answer

The general answer is: You can't, not accurately.

Assuming you're asking about RAM (physical memory) and not virtual - Windows publishes two relevant counters for each process, the total working set and the private (to the process) working set. (PerfMon will show you these.) Task Manager shows the "private" and "shared" (added together these would give the total). Process Explorer shows these as "Working Set" (the total), "WS Private", "WS Shareable", and "WS Shared". ProcExp does a little bit of "deep digging" to find the latter two.

The "shared", or the shared portion of the total, are what cause the problems.

Using the Process Explorer terms, "Shareable" shows RAM that has been allocated to the process but is at least potentially shared with other processes. And "Shared" is the subset of that actually is being shared, by at least one other process.

The trouble is that you don't know how many or which processes are actually sharing it. Adding up all of the "Shareable" or "Shared" numbers will give you a bigger total than reality, because shared pages will be counted in all of the processes that happen to be sharing them. Not every process, even processes running the same program (like Chrome), will necessarily be sharing the same pages out of their total address space, either.

For a set of processes all running the same .exe, like Chrome's: By adding together all of their "WS Private" counters, and then adding to that total the largest of any Chrome instance's "WS shareable", you will get to a minimum figure... but the actual may be larger.

Chrome does have that nice self-reporting feature mentioned by ge0rdi. The counters you want are the ones under "Memory". Chrome on my machine does not agree exactly with what the OS reports, but it's close enough for all practical uses.

Another thing to consider is that the "memory usage" of any process, or subset of processes, in a virtual memory OS is extremely dependent on the process's behavior and on RAM pressure. Run it on a system with more or less RAM, or with more or less other stuff running and demanding RAM, and the numbers will look very different. So there is not a fixed number as to how much RAM any given process "needs". So even "notice your available RAM, then close all of the Chrome instances and see how much available RAM increases" is not a good test. The OS may assign some of the released RAM to other processes, particularly if they're busy.

Related Question