xcode ios 僵尸检测

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9533650/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:30:06  来源:igfitidea点击:

ios Zombie detection

xcodeinstrumentsnszombie

提问by toom

I'm having (in my opinion) a very difficult problem in my code. It crashes randomly at different places in the code. The project is a ARC project.

我的代码中有(在我看来)一个非常困难的问题。它在代码的不同位置随机崩溃。该项目是一个ARC项目。

So my program crashes occaisonally with this messages:

所以我的程序偶尔会崩溃并显示以下消息:

malloc: *** error for object 0xd2dd8b0: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

I already set a breakpoint for malloc_error_breakbut I don't get any information out of it. When the code crashes ,XCode shows me the place in the code where it happens. But as I already said the crashes are randomly and do not occur always. But it seems as if the crashes are concentrated at on particular line in the code.

我已经为它设置了一个断点,malloc_error_break但我没有从中得到任何信息。当代码崩溃时,XCode 会向我显示代码中发生崩溃的位置。但正如我已经说过的那样,崩溃是随机的,并不总是发生。但似乎崩溃集中在代码中的特定行。

Now, I wanted to debug it using the instruments that come with xcode. After a bit of googling i found the following stuff on stackoverflow: How do I set up NSZombieEnabled in Xcode 4?and Xcode malloc error.

现在,我想使用 xcode 附带的工具来调试它。经过一番谷歌搜索后,我在 stackoverflow 上发现了以下内容:如何在 Xcode 4 中设置 NSZombieEnabled?Xcode malloc 错误

So the first link describes how to start zombie detection out of xcode itself by clicking the run button in xcode and choose "Profile". The problem I have is, that I cannot find "Zombies" when choosing the template for the trace document in my version of xcode (4.2). But if I start Instruments outside xcode (e.g. from finder) I can choose zombies.

所以第一个链接描述了如何通过单击 xcode 中的运行按钮并选择“配置文件”来启动 xcode 本身的僵尸检测。我遇到的问题是,在我的 xcode (4.2) 版本中为跟踪文档选择模板时,我找不到“僵尸”。但是如果我在 xcode 之外启动 Instruments(例如从 finder),我可以选择僵尸。

Okay, here is what I did:

好的,这是我所做的:

1) Start Instruments from finder and choose Profile "Zombies".

1) 从 finder 启动 Instruments 并选择 Profile "Zombies"。

2) Start iphone app from xcode in the iphone simulator (normal run (not profile or debug)).

2)在iphone模拟器中从xcode启动iphone应用程序(正常运行(不是配置文件或调试))。

3) In Instruments "Choose Target"->"Attach to process"->"iPhone Simulator (57529)".

3) 在仪器中“选择目标”->“附加到进程”->“iPhone 模拟器 (57529)”。

4) Instruments begins to recod something (I cannot figure out what it does).

4)仪器开始记录一些东西(我不知道它做了什么)。

5) Start playing around with the app until it crashes.

5) 开始玩这个应用程序,直到它崩溃。

Eventually the app crashes and here is a screenshot of instruments after crashing the app: enter image description here

最终应用程序崩溃了,这是应用程序崩溃后仪器的屏幕截图: 在此处输入图片说明

My questions:

我的问题:

1) Is Zombies adequate for my problem or should I use another analyizes tool?

1) Zombies 是否足以解决我的问题,还是应该使用其他分析工具?

2) What tells me instruments in it's output after crashing?

2)什么告诉我崩溃后它的输出中的仪器?

回答by Mark Szymczyk

Judging by your description of the problem, your crash is caused by something besides accessing a zombie object. If your app accesses a deallocated (zombie) object, Instruments shows a message like the following when using the Zombies template:

从您对问题的描述来看,您的崩溃是由访问僵尸对象之外的其他原因引起的。如果你的应用访问了一个释放的(僵尸)对象,当使用僵尸模板时,Instruments 会显示如下消息:

enter image description here

在此处输入图片说明