Cocoa – Understand the VM_STAT in the Mac OS, how to convert these numbers to something similar to the Activity Monitor?

I am trying to write a mac os program to monitor the system (similar to activity monitor). I checked the function vm_stat and when I run it, I get this:

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)< /pre>

But when I run Activity Monitor, I get something like:

Page Ins: 1.61gb (8.00kb/sec)
Page outs: 598.6 MB

I have a question: how to release the page in vmstat so small (compared to activity monitor)

assuming the page is 4096 words Section, then 256 is the number of pages in one megabyte (256 pages * 4096 bytes per page = 1048576 bytes, which is 220 bytes, which is 1 megabyte). The number from vm_stat is in the page, and it also tells you The page size is 4096 bytes, so you don't need to hardcode 256.> Since you don't show the activity monitor to compare I can't say for sure, but I suspect this is due to vm_stat using page units and activity monitor using "human readable "Unit, they are indeed the same value (or, if the Activity Monitor is continuously updated, turn off).

I am trying to write a mac os program to monitor the system (similar to the activity monitor ). I checked the function vm_stat and when I ran it, I got this:

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)

But when I run Activity Monitor, I get something like this:

Page Ins: 1.61gb (8.00kb/sec)
Page outs: 598.6 MB

I have a question: how to release pages in vmstat so small (with activity monitoring (Compared with the device)

Assuming that the page is 4096 bytes, 256 is the number of pages in one megabyte (256 pages * 4096 bytes per page = 1048576 Bytes, i.e. 220 bytes, i.e. 1 megabyte). The number from vm_stat is in the page, it also tells you that the page size is 4096 bytes, so you don't need to hard code 256.> Since you are not showing the Activity Monitor For comparison I can't say with certainty, but I suspect this is due to the fact that vm_stat uses page units and Activity Monitor uses "human readable" units, and they are indeed the same value (or, if Activity Monitor is continuously updated, it is closed). /p>

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1127 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.