How to retrieve the % of memory pressure using native libraries

Is there any way to retrieve the memory pressure percentage using native libraries?

When I run the memory-pressure command, I can see the percentage of free memory, but I’d like to retrieve the same information using a native library.

Answered by DTS Engineer in 864218022
Is there any way to retrieve the memory pressure percentage using native libraries?

Be careful here. In any non-trivial VM-based OS, free memory isn’t a useful statistic. I talk about this in On Free Memory.

In most cases you want to respond to memory pressure notifications. You can get those via Dispatch; see the makeMemoryPressureSource(eventMask:queue:) function.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer
Is there any way to retrieve the memory pressure percentage using native libraries?

Be careful here. In any non-trivial VM-based OS, free memory isn’t a useful statistic. I talk about this in On Free Memory.

In most cases you want to respond to memory pressure notifications. You can get those via Dispatch; see the makeMemoryPressureSource(eventMask:queue:) function.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How to retrieve the % of memory pressure using native libraries
 
 
Q