iOS僵尸检测 [英] ios Zombie detection

查看:218
本文介绍了iOS僵尸检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

所以我的程序偶尔会因以下消息而崩溃:

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

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

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

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

好的,这就是我所做的:

1)从查找器中启动乐器",然后选择配置文件僵尸".

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

3)在选择目标"->附加到处理"->"iPhone模拟器(57529)"中.

4)乐器开始掩盖某些东西(我无法弄清它的作用).

5)开始试用该应用程序,直到崩溃为止.

最终,应用程序崩溃了,这是应用程序崩溃后仪器的屏幕截图:

我的问题:

1)僵尸足以解决我的问题吗?还是应该使用其他分析工具?

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

解决方案

从对问题的描述来看,您的崩溃是由访问僵尸对象以外的其他原因引起的.如果您的应用访问已释放的(僵尸)对象,则在使用僵尸"模板时,Instruments会显示如下消息:

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.

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_break but 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.

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.

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.

Okay, here is what I did:

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

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

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

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

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

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

My questions:

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

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

解决方案

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:

这篇关于iOS僵尸检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆