如何在 Xcode 中启用 NSZombie?

发布于 2024-07-30 17:40:58 字数 110 浏览 7 评论 0原文

我有一个崩溃的应用程序,没有错误跟踪。 如果我进行调试,我可以看到正在发生的部分情况,但无法弄清楚哪个对象是“僵尸”。

有人知道如何在 Xcode 4 中启用 NSZombie 吗?

I have an app that is crashing with no error tracing. I can see part of what is going on if I debug, but can't figure out which object is "zombie-ing".

Does anybody know how to enable NSZombie in Xcode 4?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(15

仙女 2024-08-06 17:40:58

环境变量现在是“方案”的一部分。

要编辑方案并打开僵尸:

  • 在“产品”菜单中,选择“方案”> “编辑方案...”。

  • 转到左侧面板中的“Run Foo.app”阶段,以及右侧面板中的“Arguments”选项卡。

  • NSZombieEnabled 添加到“环境变量”部分,并将值设置为 YES,就像在 Xcode 3 中一样。


在 Xcode 4.1 及更高版本中, “运行”阶段的“诊断”选项卡上还有一个“启用僵尸对象”复选框。


使用 Xcode 6.4:

屏幕截图

Environment variables are now part of the "scheme".

To edit the scheme and turn on zombies:

  • In the "Product" menu, select "Scheme" > "Edit Scheme...".

  • Go to the "Run Foo.app" stage in the left panel, and the "Arguments" tab on the right.

  • Add NSZombieEnabled to the "Environment Variables" section and set the value to YES, as you could in Xcode 3.


In Xcode 4.1 and above, there's also a checkbox on the "Diagnostics" tab of the "Run" stage to "Enable Zombie Objects".


With Xcode 6.4:

Screenshot

深爱成瘾 2024-08-06 17:40:58

我在排查 EXC_BAD_ACCESS 时遇到了同样的问题,并且很难在 Xcode 4.2(iOS5 SDK 附带的最新版本)中找到该设置。 苹果不断地改变事物,设置也不再像以前那样了。

幸运的是,我找到了它并且它适用于该设备,而不仅仅是模拟器。 您需要在 Xcode 中打开“产品”菜单,选择“编辑方案”,然后选择“诊断”选项卡。 在那里你有“启用僵尸对象”。 一旦选择并在调试器中运行,您将指向双重释放的对象! 享受!

简而言之

Product->Edit Scheme->Diagnostics-> Click Enable Zombie Objects

I encountered the same problem with troubleshooting EXC_BAD_ACCESS and had hard time to find the setting with Xcode 4.2 (the latest one that comes with iOS5 SDK). Apple keeps on moving things and the settings are no longer where they used to be.

Fortunately, I've found it and it works for the device, not just Simulator. You need to open the Product menu in the Xcode, select Edit scheme and then choose the Diagnostics tab. There you have "Enable Zombie Objects". Once selected and run in debugger will point you to the double released object! Enjoy!

In short

Product->Edit Scheme->Diagnostics-> Click Enable Zombie Objects
薄荷→糖丶微凉 2024-08-06 17:40:58

产品> Profile 将启动 Instruments,然后您应该有一个名为“Zombies”的“跟踪模板”。 但是,此跟踪模板仅在当前构建目标是模拟器时才可用 - 如果您将目标设置为 iOS 设备,则该跟踪模板将不可用。

另一件需要注意的事情是,乐器库中没有实际的 Zombies 乐器。 僵尸跟踪模板实际上由具有“启用 NSZombie 检测”启动配置集的分配工具组成。

Product > Profile will launch Instruments and then you there should be a "Trace Template" named "Zombies". However this trace template is only available if the current build destination is the simulator - it will not be available if you have the destination set to your iOS device.

Also another thing to note is that there is no actual Zombies instrument in the instrument library. The zombies trace template actually consists of the Allocations instrument with the "Enable NSZombie detection" launch configuration set.

甜妞爱困 2024-08-06 17:40:58

在可执行文件上设置环境变量(NSZombieEnabled = YES),然后正常运行/调试您的应用程序,这很简单。如果您向僵尸发送消息,您的应用程序将崩溃/中断到调试器,并且NSLog 给您的一条消息。

有关更多信息,请查看此 CocoaDev 页面:http://www.cocoadev.com/index。 pl?NSZombieEnabled

此外,随着 10.6 以及 Xcode 和 Instruments 的下一版本的发布,这个过程将变得更加容易。 只是说'。 =)

It's a simple matter of setting an environment variable on your executable (NSZombieEnabled = YES), and then running/debugging your app as normal.If you message a zombie, your app will crash/break to debugger and NSLog a message for you.

For more information, check out this CocoaDev page: http://www.cocoadev.com/index.pl?NSZombieEnabled

Also, this process will become much easier with the release of 10.6 and the next versions of Xcode and Instruments. Just saying'. =)

蓝礼 2024-08-06 17:40:58

产品> 配置文件将弹出仪器。 从面板中选择僵尸并发疯。

Product > Profile will pop up Instruments. Select zombies from the panel and go nuts.

莫相离 2024-08-06 17:40:58

转到产品 - 方案 - 编辑方案 - 参数 - 环境变量 设置 NSZombieEnabled = YES

在此处输入图像描述

在此处输入图像描述

Go to Product - Scheme - edit scheme - Arguments - Environment Variables set NSZombieEnabled = YES

enter image description here

enter image description here

清音悠歌 2024-08-06 17:40:58

在 xcode 4.2 中

转到,产品 -> 编辑方案-> 单击运行 yourappname.app -> 诊断-> 启用僵尸对象。

In xcode 4.2

Goto, Product -> edit scheme -> click Run yourappname.app -> Diagonostics -> Enable Zombie object.

若相惜即相离 2024-08-06 17:40:58

以下是如何使用 Instruments 和 NSZombie 查找并修复 iOS 上的内存崩溃的视频和说明:
http://www.markj.net/iphone-memory-debug-nszombie/

Here's a video and explaination how to use Instruments and NSZombie to find and fix memory crashes on iOS:
http://www.markj.net/iphone-memory-debug-nszombie/

酒绊 2024-08-06 17:40:58

从 Xcode 3.2.5 和 Snow Leopard (Mac OS X 10.6) 开始,您可以通过 Zombies 工具运行代码: Run > 使用性能工具运行> 僵尸。 这使您可以在时间轴上查看特定对象及其保留计数。

As of Xcode 3.2.5 and Snow Leopard (Mac OS X 10.6), you can run your code through the Zombies instrument: Run > Run with Performance Tool > Zombies. That allows you to see particular objects and their retain counts on a timeline.

橙幽之幻 2024-08-06 17:40:58

在 Xcode 4.5.2 中转到产品 -> 编辑方案-> 在“诊断”选项卡下,选中“Objective C”和“启用僵尸对象”之间的复选框,然后单击“确定”

In Xcode 4.5.2 goto Product -> Edit Scheme -> and Under the Diagnostics tab check the check box in between Objective C and Enable Zombie Objects and Click on OK

只想待在家 2024-08-06 17:40:58

要启用 Zombie 日志记录,请双击 Xcode 项目的可执行文件组中的可执行文件。 此时,单击“参数”选项卡,然后在“环境中要设置的变量:”部分中,创建一个名为“NSZombieEnabled”的变量,并将其值设置为“YES”代码>.

To enable Zombie logging double-click the executable in the executables group of your Xcode project. At this point click the Arguments tab and in the Variables to be set in the environment: section, make a variable called NSZombieEnabled and set its value to YES.

岁吢 2024-08-06 17:40:58

在 XCode 4.0 中:要在 Instruments 中检测 NSZombie,请选择模拟器作为目标(无法检测设备上的 NSZomboe)。 运行 Instruments (CMD+I) 并选择“Zombies”跟踪模板。 享受。

In XCode 4.0: To detect NSZombie in Instruments, select the Simulator as your target (can't detect NSZomboe on device). Run Instruments (CMD+I) and select "Zombies" trace template. Enjoy.

习惯成性 2024-08-06 17:40:58

在可执行文件的首选项中添加环境变量 NSZombieEnabled 并将值设置为 YES

In the preferences of your executable add the environment variable NSZombieEnabled and set the value to YES.

路还长,别太狂 2024-08-06 17:40:58

在你的 XCODE (4.3) 中,点击播放按钮:)(运行)

选择:编辑方案

方案管理窗口将打开,

单击“参数”选项卡,

您应该看到:1-启动时传递的参数
2-环境变量

里面(2-环境变量)的地方
名称:NSZombieEnabled
值:是

并且完成了......

in ur XCODE (4.3) next the play button :) (run)

select : edit scheme

the scheme management window will open

click on the Arguments tab

you should see : 1- Arguments passed on launch
2- environment variables

inside the the (2- environment variables) place
Name: NSZombieEnabled
Value: YES

And its done....

画▽骨i 2024-08-06 17:40:58

NSZombieEnabled 用于调试 BAD_ACCESS,

从 Xcode 的方案表中启用 NSZombieEnabled 环境变量。

点击“产品”⇒“编辑方案”打开工作表并设置“启用僵尸对象”复选框

视频 将帮助您了解我想说的内容。

NSZombieEnabled is used for Debugging BAD_ACCESS,

enable the NSZombiesEnabled environment variable from Xcode’s schemes sheet.

Click on Product⇒Edit Scheme to open the sheet and set the Enable Zombie Objects check box

this video will help you to see what i'm trying to say.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文