Running ps -ax -O 'rss user %mem
should summon all the processes that are currently contributing to either Active or Wired , in the Mac definitions of
"Active + Wired + Inactive + Free = Total Physical Memory" , right?
Activity Monitor was showing high Active mem usage and hand-counting showed low numbers, so I re-counted with the below awk script.
Note the Activity Monitor screenshot 1 for 'Active' and 'Wired'. At the time of capture, 'root' processes show ~377MiB and the not-root total ~1805MiB is close.
total: root 376632 KiB, and active 1805476 KiB , percent : 51.9
% root 8.4
% active 43.5
However, closing Chrome makes the problem clearer. I have an Activity Monitor screenshot 2 , with script output. Here, neither Active nor Wired memory matches.
total: root 365968 KiB, and active 643880 KiB , percent : 23.6
% root 8.2
% active 15.4
mem_count.sh:
3 ps -axmc -O 'rss user %mem' | awk '
4
5 BEGIN {
6 root = 0 ; active = 0 ; percent_root = 0.0 ;
7 percent_active = 0.0 ; percent = 0.0 ;
8 }
9
10 {
11 percent += $4
12 if ( $3 == "root") {
13 root += $2
14 percent_root += $4 ;
15 }
16 else {
17 active += $2
18 percent_active += $4 ;
19 }
20
21 }
22 END {
23 print "total: root ", root, "KiB, and active ", active , "KiB , percent : ", percent ;
24 print "% root " , percent_root
25 print "% active " , percent_active
26 }'
sample output
$ ps -axmc -O 'rss user %mem'
PID RSS USER %MEM TT STAT TIME COMMAND
37 160964 root 3.8 ?? Ss 20:22.92 mds
...
This is causing a bit of a headache. Image Ref:
top
. It's different from its Linux counterpart and does support programmatic output parsing like e.g. here.