I'm trying to write automation for memory leak testing of a website. I can see a memory leak by going between two pages so I have selenium automate going back and forth between them. Before the process, after each iteration of going between those pages, and after ~150 repetitions I want to know how much the memory usage of each browser changes.
Using chrome as an example I tried using tasklist | find "chrome.exe"
and totaling up the memory usage output for all those processes. I'm not sure if I'm doing something wrong or if it's giving me different data than I'm thinking it's supposed to, but tasklist
is giving me different numbers than Task Manager for memory usage.
Just trying it now the total memory usage between all the chrome.exe entries in tasklist
showed 1259MB, but task manager shows ~530MB. Additionally after doing 150 iterations tasklist
yesterday was showing ~1800MB (and memory usage had plateaued and didn't go any higher) but Task Manager was showing ~3300MB used and still going up. Closing that tab dropped chrome's memory usage in Task Manager to ~700MB. If left to run longer the browser would eventually crash, so the signs of a memory leak can't be seen using tasklist
as I am, but can be seen in Task Manager.
Why are tasklist
and Task Manager giving different measurements? Is there a way I can get the numbers Task Manager is providing from the command line so I can automate it? I was experimenting with
https://docs.microsoft.com/en-us/windows/desktop/api/Psapi/nf-psapi-getprocessmemoryinfo but I'm not sure if it's the information I'm looking for?
Best Answer
Why are tasklist and Task Manager giving different measurements?
By default Task Manager displays the memory as "Memory - Private Working Set".
If you choose the column "Memory - Working Set" you will see the same values displayed as tasklist.
I'm running ProcessHacker (not TaskMan) so the following screen shot is slightly different but give you an indication of the difference:
See below links for more information on the difference between private memory and working set memory.
Further Reading