如何在 Lion 下的 Xcode 4.1 Instruments 中启用 NSZombie?
这仅涉及新的 Xcode 4.1,特别是在 Lion 上运行。如何在 Instruments 中启用 NSZombie?它不再像 Xcode 4.0 那样位于启动配置下的 (i) 图标的分配中。图书馆也没有名为“僵尸”的条目。
当然,问题是我无法回退到 Xcode 4.0,因为它拒绝在 Lion 下运行,所以我陷入了困境!还有其他使用 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
关于我自己的问题,我从苹果公司得到了这个非常有用的答案。它是逐字记录的 -
ME:是否有关于如何使用 Xcode 4.1.1 和/或 Instruments 查找那些困难的已释放对象、在设备上进行测试的更新?
苹果:首先,上面[苹果论坛]中显示的黑客行为已因操作系统的内部更改而被废弃,也就是说,Zombie 设置现在由 CF 完成。您可以使用下面所示的代码强制启用僵尸:
extern void _CFEnableZombies(void);
int main(int argc, char **argv)
{
_CFEnableZombies();
重要提示
:_CFEnableZombies 函数是私有的,因此您甚至不需要考虑将此代码放入生产应用程序中。然而,这并不是什么秘密。您可以通过查看 Lion 的 Darwin 开源来了解它是如何实现的。
http://www.opensource.apple.com/source/CF /CF-635/CFRuntime.c
如果您这样做,当您向僵尸发送消息时,您的应用程序将停止(断点例外),无论您如何运行它。因此,您可以使用分配工具在仪器中运行它,并获得僵尸检测和分配跟踪。
请注意,当向僵尸发送消息时,系统会打印如下内容:
*** -[ ]: message sent to deallocated instance "
这不会出现在 Instruments 控制台区域中;您必须使用 Xcode Organizer(或 iPCU) )来
分享并欣赏
奎因“爱斯基摩人!”
Apple 开发者关系、开发者技术支持、核心操作系统/硬件
ME:希望这对处于这种情况的某些人来说是有用的信息。
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();
}
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:
还有另一种方法可以在设备上运行 NSZombie,但这是通过 XCode 4 而不是仪器来完成的。
要在设备上使用 NSZombie 运行,请打开 XCode 项目并单击顶部菜单项“产品”,然后按住 Alt 并单击“运行”,这将打开一个单独的窗口,您将在窗口底部看到“环境变量” 。点击“+”并输入“NSZombieEnabled”作为名称,“YES”作为值。
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.