I've got an ios email app and everything is working well, except with one particular users account info I get crashes related to what look like an overreleased object.
The problem is that if I enable NSZombies (or use Instruments) the crash doesn't happen. It will occur every time when NSZombies is disabled, but when I want to see what is over released the app performs as expected.
So my question is, how do I track this down if enabling Zombies prevents it from occurring? Also what exactly is Zombies doing to prevent the crash, is it hanging onto the object to monitor it?
So my question is, how do I track this down if enabling Zombies prevents it from occurring?
Use less -autorelease
s, if possible.
You might consider Malloc Stack Logging to narrow down what the allocation is, or the callsite.
Creating local autorelease pools may also help you identify the scope.
Sometimes, Memory Scribbling or Guard Malloc can help.
Just running on the Sim/Device could induce a difference -- or even a different device model.
Removing all other memory issues (e.g. leaks, circular references) can also help get you closer to identifying this issue.
You might also consider checking the address, in the event it is a tagged pointer.
Even introducing messaging in more places can help narrow down the scope. [obj self]
would be an error if obj
is a zombie.
Also what exactly is Zombies doing to prevent the crash, is it hanging onto the object to monitor it?
Yes. An object's -dealloc
will be called as usual, but (generally) the memory used by the allocation will not be returned, and the instance will become a zombie - an instance which produces a runtime error if messaged.