开发者

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


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.


It's a distinct instrument:

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


There is another way to run with NSZombie on the device, but this is done through XCode 4 not instruments.

To run with NSZombie on the device open your XCode Project and click on the top menu item "Product" then hold down alt and click "Run" this will open a separate window where you will see "Environment Variables" in the bottom of the window. Hit the "+" and enter "NSZombieEnabled" for the name and "YES" for the value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜