Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you enable NSZombie in Instruments of Xcode 4.1 under Lion?

This is ONLY regarding the new Xcode 4.1, specifically running on Lion. How do you enable NSZombie in Instruments ? It is no longer in Allocations in the (i) icon under Launch Configuration as in Xcode 4.0. Nor is there a Library entry called Zombies.

Of course the problem is I cannot fall back to Xcode 4.0 because it refuses to run under Lion, so I'm in a pickle ! Any other bleeding edge developers using Lion who, with more experience than myself, can help dig this out ? Thanks. -Ric

like image 559
Ric Avatar asked Dec 17 '22 11:12

Ric


2 Answers

I got this very useful answer from Apple regarding my own question. It is verbatim -

ME: Is there an update as to how to find those tough deallocated objects, testing on the device, using Xcode 4.1.1 and/or Instruments ?

APPLE: First up, the hack shown above [in Apple's Forum] has been obsoleted by internal changes to the OS, namely, Zombie setup is now done by CF. You can force zombies enabled using the code shown below:

extern void _CFEnableZombies(void);

int main(int argc, char **argv) { _CFEnableZombies();

... rest of your main ...

}

IMPORTANT: The _CFEnableZombies function is private, so you don't even think about putting this code into a production app. However, it's not secret; you can see how it's implemented by looking in the Darwin open source for Lion.

http://www.opensource.apple.com/source/CF/CF-635/CFRuntime.c

If you do this, your app will stop (with a breakpoint exception) when you message a zombie, regardless of how you run it. So you can run it in Instruments with the Allocations instrument and get both zombie detection and allocation tracking.

Note that when a zombie is messaged the system prints something like this:

*** -[ ]: message sent to deallocated instance "

This doesn't appear in the Instruments console area; you'll have to use the Xcode Organizer (or iPCU) to view it.

Share and Enjoy

Quinn "The Eskimo!" Apple Developer Relations, Developer Technical Support, Core OS/Hardware

ME: hope that is useful info for some of you in this situation.

like image 89
Ric Avatar answered Dec 28 '22 08:12

Ric


It's a distinct instrument:

Zombies as a separate instrument

like image 43
magma Avatar answered Dec 28 '22 07:12

magma