iosmemory-leaksnszombieenabled

Why am I seeing all these leaks when NSZombie is enabled?


I am nearing completion on my first app and I'm suddenly seeing that the app is causing memory leaks. I have found a few leaks and fixed them. Now there are no leaks but to my surprise when NSZombie is enabled it is showing more than 4000 leaks which are mainly from frameworks.

I am confused with the exact use of NSZombie. Is it only used for finding the zombies or is it in any way useful for finding leaks?

Here is a screenshot that shows all the leaks which are associated with the frameworks:

Screenshot for leaks


Solution

  • I believe the command line option 'NSDeallocateZombies' defaults to NO. So zombies are never deallocated and thus appear as leaks if zombies (NSZombiesEnabled) are on. Never test for leaks with zombies on. You can turn NSDeallocateZombies to YES as well but I'm not sure how that interacts with Instruments. A zombie is a special object that responds to all messages with an exception. In order to make this useful it has to live a long time (so you can catch when you try to reuse a deallocated object) but that makes it look exactly like a leak.