Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not getting didReceiveMemoryWarning when app is in the background

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?

like image 355
fieldtensor Avatar asked May 20 '11 22:05

fieldtensor


1 Answers

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.

like image 89
Hollance Avatar answered Nov 19 '22 16:11

Hollance