Search code examples
iosout-of-memoryexc-bad-accessnszombie

Enabling Zombie Objects causing memory pressure crashing


My app is crashing when its deallocating a ViewController. I believe there is an object in there causing it - I am getting a EXC_BAD_ACCESS crash.

It happens usually after finishing a level of the game and returning to the menu.

In trying to diagnose the issue, I turned on Enable Zombie Objects in the Schemes. As I play the level to recreate the issue my memory fills up and I start getting a 'Got memory pressure notification (critical)' warning. And then the app crashes with a 'Message from debugger: Terminated due to memory issue'

Is there a way to enable Zombie Objects on just one ViewController and it's contents so I'm not retaining objects I know don't matter?

Or does anyone have suggestions for what I could try other then Zombies?

Or any other advice?

Thanks, -Mark


Solution

  • There's no surprise here.

    Zombies are memory leaks. That is exactly how they work. The whole idea is that no objects go out existence. That is what it means to be a zombie!

    Thus, if you run the app for too long with zombies on, you will leak so much memory that you crash.

    can i enable zombie object on individual objects

    No, that's not an option. You could perhaps try to make a highly reduced version of your app, one that produces the issue but with less memory usage, and run zombies on that.