I'm using MacOS 11.6. I've written a small cron job that measures memory usage of a process and, if that usage exceeds a threshold, pops up a notification on screen. (The point is to remind me when a leaky process gets so big that it's time to restart it.)
All of this works just fine except the memory usage calculated by my technique never matches what iStat Menus reports (mine is always lower) and I find that iStat Menus numbers are a better predictor of when I need to restart a process. Yes, I can just set my own thresholds lower but I want to learn how iStat Menus is calculating their numbers. I have tried many ways but I can't get a number that matches theirs. Here is my current command:
ps ax -o rss,command | fgrep -i firefox | awk '{s+=$1}END{print s/1024/1024}'
(The issue is not unique to measuring Firefox. Same for Apple Mail and any other. The delta varies though: for Firefox, I've seen my technique almost 1GB lower than iStats.)
Any ideas on how iStats is doing their measurement?
0 Answers