soyuka / pidusage

Cross-platform process cpu % and memory usage of a PID
MIT License
512 stars 55 forks source link

Memory usage is RAM and not Total ? #134

Closed ssg3d closed 2 years ago

ssg3d commented 3 years ago

I compared pidusage=>stats.memory readings with resource monitor readings. It seems more close to "working set", and does not take into account "commit". Running my node app on a machine with low (1 GB RAM) keeps the working set to 500 ish MB but the commit hikes up to as much as 1.5 GB. If I wish to act on the "total memory" consumption of my child process and decide to kill it if it goes beyond a limit, I cant do so. Any suggestions please?

soyuka commented 2 years ago

Please note that if you need to check a Node.JS script process cpu and memory usage, you can use process.cpuUsage and process.memoryUsage since node v6.1.0. This script remain useful when you have no control over the remote script, or if the process is not a Node.JS process.