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.
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"