views:

191

answers:

0

According to Apple... apps should reduce their memory footprint as much as possible when running in the "background" (suspended mode). I reduce the memory footprint of my app by releasing a bunch of 2D textures in ApplicationDidEnterBackground and reloading the same textures in ApplicationWillEnterForeground. Everything works for the most part.

Here is my question: Why do I get a SIGABRT or EXEC_BAD_ACCESS when I move my app to/from the background rapidly? The errors occur when the app is coming back into the foreground (textures are being reloaded).

I don't receive any errors when I move the app to/from the background less rapidly. How can I prevent this? Perhaps I should be checking if the resources are actually deallocated before I try to reload them?

How does one code defensively in this situation?