Search code examples
xcodememory-leaksinstrumentsnszombie

XCode Zombies shows CFArray increasing Live Bytes


I've not used Zombies before, and must admit I'm not that sure what it's doing. However, one thing concerns me:

CFArray seems to be continually increasing its Live Bytes and # Living columns, along with a couple of mallocs, which I presume are related. This is when my app is just sitting there, rendering (OpenGL) and waiting for input.

I've tried running the leaks instrument, and that doesn't show that I'm getting memory leaks during this period, or even any more allocations. No allocations on anything, let alone CFArray.

So which of the two instruments should I believe? Or is it simply that I don't understand what the Zombies instrument is actually doing?

If there's any decent documentation on Zombies that anyone could point me to, that would be cool. Apple's docs seem to gloss over it a bit.


Solution

  • NSZombies basically replaces deallocated objects with a placeholder to notify the developer if it has been accessed after a dealloc (obviously a bad thing). This helps resolve retain / release issues.

    By turning it on, your app is going to appear like it is leaking memory like a sieve because nothing will ever truly be deallocated. Generally, I use NSZombies to look for specific crashers during debugging (or you can turn on Zombies in the Allocations instrument - which should also warn you that memory usage will only go up)... I use Leaks or Allocations w/Heap Shots in instruments to do memory analysis on a functioning app.

    Another good question / answer on SO: What is NSZombie?