Amit Khandelwal
Amit Khandelwal

Reputation: 185

How to calculate App and Cache Memory Like Activity Monitor in objective C in mac?

I am trying to write a MAC OSX program to monitor the system (something similar to the activity monitor).I am using vm_statistics64_data_t to get "free_count , active_count, inactive_count" etc.

But I am unable to calculate App memory correctly. I have used

"vm_page_size * vmStats.internal_page_count"

to calculate the app memory but it is not synchronized with activity monitor.

Upvotes: 4

Views: 1213

Answers (2)

D0miH
D0miH

Reputation: 122

For those who found this question and ask themselves how to calculate the "Cached Files" like in Activity Monitor:

vm_page_size * (vm_stat.external_page_count + vm_stats.purgable_count)

Upvotes: 0

Anton Simakov
Anton Simakov

Reputation: 303

It looks like you already have found the answer. Will leave it here for someone who may find this helpful.

To calculate App Memory value consistent with the Activity Monitor you need to:

vm_page_size * (vm_stat.internal_page_count - vm_stat.purgeable_count)

Upvotes: 3

Related Questions