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?
It's not that there are two levels of warning--not in terms of, like, "you have a little memory left" and then "you have less memory left". It's that the same "low memory" warning gets fired two places. Once on the UIViewController subclass currently in view (and, if that UIVC doesn't implement didReceiveMemoryWarning
, then it'll bubble up to the top of the view controller stack) and again on the Application Delegate in applicationDidReceiveMemoryWarning
. One's not a "worse" warning than the other, they're just two different hooks for implementing a response to the same warning from the OS.
It's one of the quirks of the platform that you can't really know how much memory you'll have available at any time. Background apps (mail, phone, etc) suck as much RAM as they need, and you're left to get the rest, and the only way you can know you've gotten too big is when the OS says so.
It's important to respond appropriately, by ditching resources you don't need right now. Start with the low-hanging fruit--anything big you're keeping around for later. Images, for instance, that you can ditch and then pull from a server or from disk later when you need them again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With