Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question
    
Please have a look at What is wired memory first. If this doesn't answer your question, commend or amend the question here. –  patrix Feb 9 '13 at 13:11
2  
@patrix Those answers have no bearing on my question. I understand what all five types of pages are and what they do. My question is about why the sum of the amounts of each type of page is not equal to the number of pages. This could mean there is a type of page I am unfamiliar with, a bug in vm_stat, no way to get a clean snapshot of the system because the calls vm_stat uses aren't atomic (which I would count as a bug, but others would not), or something I haven't thought of. –  Chas. Owens Feb 9 '13 at 13:28
add comment

1 Answer

Short answer: the host_statistics64() function returns the bad data.

Still looking into why this is the case, but the bug (if it is a bug) is in the library vm_stat uses, not in vm_stat itself.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.