Score:0

How to duplicate iStat Menus memory usage from a shell?

cn flag

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?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.