4

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

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
vijaykumarg
  • 181
  • 1
  • 16

2 Answers2

5

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.

ahwulf
  • 2,584
  • 15
  • 29
  • Brilliant !!! NSDellocateZombie defaults is NO in my case. I have turned it On and no more leaks are showing. As you have suggested not to test the leaks with zombies on, it looks like a perfect solution to my problem. Thanks for the reply. – vijaykumarg May 30 '12 at 04:59
1

if NSZombie is enable a "release" do not free the memory. NSZombie is used for test if you use a object already released

JMBise
  • 680
  • 4
  • 19
  • Ok I get it now, NSZombie is used only to check whether we are sending a message to the dellocated object. Please correct me if I am wrong.. – vijaykumarg May 30 '12 at 04:36
  • Yes, This is the tool to use when trying to track down over-releases and premature releases. You can read a explanation here: http://cocoadev.com/wiki/NSZombieEnabled – JMBise May 30 '12 at 06:28
  • Thanks for the link. Perfectly apt. – vijaykumarg May 30 '12 at 09:18