As far as I know there are 2 levels of memory warnings. applicationDidReceiveMemoryWarning doesn’t come with the warning level. Is there a way to get this information?
As far as I know there are 2 levels of memory warnings. applicationDidReceiveMemoryWarning doesn’t
Share
I’m adding this as a separate answer than my other one, because it IS a separate answer. The answer I gave earlier is the practical one, the one you SHOULD use. It boils down to “deal with the one level of memory warning you’re notified with and don’t concern yourself with the details”.
If, however, you really really want to know more about it, check out this undocumented API: http://www.opensource.apple.com/source/Libc/Libc-594.1.4/include/libkern/OSMemoryNotification.h
That’s the header for kernel code that generates memory warnings, and it declares the following typedef:
We obviously don’t have the implementation of the key method (
OSMemoryNotificationCurrentLevel()) that does the math to say which warning to return, but that’s the list of possible return values.You could use the Mach.h library to test the actual memory levels on the device (let me know if you want some code that does that), and then use
OSMemoryNotificationCurrentLevel()to get the current level of memory warning, and really map out the notification level to the physical state of the machine. Such an app would be completely unwelcome on the app store, and it wouldn’t really help you any in real life development, where your job is to respond to the single level of low memory warning you receive.