Cocoa 了解mac os中的vm_stat,如何将这些数字转换为类似于activity monitor的数字?
我正试图编写一个mac os程序来监视系统(类似于活动监视器)。我已经查看了函数vm_stat,当我运行它时,我得到了以下结果:Cocoa 了解mac os中的vm_stat,如何将这些数字转换为类似于activity monitor的数字?,cocoa,memory,virtual-memory,activity-monitor,Cocoa,Memory,Virtual Memory,Activity Monitor,我正试图编写一个mac os程序来监视系统(类似于活动监视器)。我已经查看了函数vm_stat,当我运行它时,我得到了以下结果: Mach Virtual Memory Statistics: (page size of 4096 bytes) Pages free: 438386. Pages active: 236438. Pages inactive: 113
Mach Virtual Memory Statistics: (page size of 4096 bytes)
Pages free: 438386.
Pages active: 236438.
Pages inactive: 113750.
Pages speculative: 34293.
Pages wired down: 225027.
"Translation faults": 11132566.
Pages copy-on-write: 319385.
Pages zero filled: 6618647.
Pages reactivated: 23071.
Pageins: 421804.
Pageouts: 153240.
Object cache: 14 hits of 24183 lookups (0% hit rate)
但是,当我运行“活动监视器”时,我得到如下结果:
Page Ins: 1.61gb (8.00kb/sec)
Page outs: 598.6 MB
关于这一点,我有一个问题:为什么vmstat中的免费页面这么小(与活动监视器相比)
256页*4096字节/页=1048576字节
aka 220字节aka 1兆字节),假设一页为4096字节。vm_stat中的数字是以页面为单位的,它还告诉您页面大小是4096字节,因此您不必硬编码256字节vm_stat
使用了页面的一个单元,而活动监视器使用了“人类可读”的单元,并且它们确实是相同的值(或者关闭,因为活动监视器不断更新)