I'm noticing that my view controllers aren't getting their didReceiveMemoryWarning
methods called when my application is in the background state on the iPad simulator. More specifically, I see the call to applicationDidEnterBackground
in my logs, then I hit the "Simulate Memory Warning" button, and then I notice a peculiar lack of any didReceiveMemoryWarning
calls.
However, when I bring the application back to the foreground I suddenly get the didReceiveMemoryWarning
call, as if it had been queued.
What I'm confused about here is if my application is really in the background, or if it's just flat out suspended. Is there any way to tell in the simulator?
Also, if it is not yet suspended, and really is just in the background, then I would find it silly that I'm unable to process didReceiveMemoryWarning
. Because that would then mean that only the foreground application can process memory warnings to free up space, which is of course odd given that the foreground app could be only one of possibly dozens of running apps, and it would make so much more sense if they could all free up memory.
Anyway, the main questions are: why aren't I getting didReceiveMemoryWarning
in the background state? And also, am I really suspended? And how do I tell?
I don't think that is the case. I am able to access didReceiveMemoryWarning code while in background. Once system generates low memory signal than as a good citizen we should release the memory. This also helps our app from terminating by the system.
If you did not start a background task, or do VOIP, location tracking or audio in the background, then your app is suspended after applicationDidEnterBackground. It will not get any notifications. Any notifications are kept around (even those that occur after the app was suspended) and sent to the app when the app goes to the foreground again.