When I run vm_stat
on my 10.6.8 MacBook Pro with 2 GB of RAM I get the following:
Mach Virtual Memory Statistics: (page size of 4096 bytes)
Pages free: 90518.
Pages active: 205479.
Pages inactive: 32417.
Pages speculative: 134461.
Pages wired down: 61009.
"Translation faults": 26323651.
Pages copy-on-write: 177180.
Pages zero filled: 15230394.
Pages reactivated: 3.
Pageins: 388108.
Pageouts: 0.
Object cache: 14 hits of 797355 lookups (0% hit rate)
If you add up the free, active, inactive, speculative, and wired memory and multiply by 4096 (to turn the pages into bytes), you get 2,145,828,864 rather than the expected 2,147,483,648. There are 1,654,784 missing bytes (or 404 pages). This isn't a constant number though, it fluctuates:
$ vm_stat 1 | perl -MList::Util=sum -nle 'next unless /^\s*\d/; print 524288-sum((split)[0 .. 4])'
193
147
146
60
57
220
215
385
379
285
283
194
Are these missing pages just a reporting inaccuracy because the amount of one type of page has changed by the time vm_stat
prints the next type of page? Or is there some other type of memory that I am missing?
vm_stat
, no way to get a clean snapshot of the system because the callsvm_stat
uses aren't atomic (which I would count as a bug, but others would not), or something I haven't thought of.