NSZombies正在吃我的应用程序的大脑! [英] NSZombies are eating my app's brain!

查看:127
本文介绍了NSZombies正在吃我的应用程序的大脑!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个保留/释放问题。我的视图是相当复杂,所以我设置NSZombieEnabled为YES,我试图找到哪个,确切地,对象是导致我的悲伤。为了加快这个过程沿着我想知道是否有提示或技巧跟踪僵尸回到坟墓,他们挖出他们的方式(对不起,不得不),或回到他们相关联的对象?隐藏的控制台消息似乎没有提供很多见解:

I've got a retain/release problem. My View is pretty complicated so I've set NSZombieEnabled to YES and am trying to locate which, exactly, object is causing me grief. To speed this process along I'm wondering if there hints or tricks to tracking the Zombies back to the grave they dug their way out of (sorry, had to) or, back to the object they're associated with? The cryptic console message doesn't appear to offer much insight:

NSInvocation: warning: object 0x1076850 of class '_NSZombie_CALayer' does not implement methodSignatureForSelector: -- trouble ahead

我没有选择器称为麻烦事。

I have no selectors called "trouble ahead".

编辑 - 包括堆栈跟踪:

Edit - Including Stack Trace:

#0  0x3026e017 in ___forwarding___
#1  0x3024a0a2 in __forwarding_prep_0___
#2  0x302042e8 in CFRelease
#3  0x00c4fc31 in CALayerUpdateSublayers
#4  0x00c4e173 in -[CALayer dealloc]
#5  0x00c4000e in CALayerRelease
#6  0x00c48dad in CALayerFreeTransaction
#7  0x00c410b8 in CA::Transaction::commit
#8  0x00c492e0 in CA::Transaction::observer_callback
#9  0x30245c32 in __CFRunLoopDoObservers
#10 0x3024503f in CFRunLoopRunSpecific
#11 0x30244628 in CFRunLoopRunInMode
#12 0x32044c31 in GSEventRunModal
#13 0x32044cf6 in GSEventRun
#14 0x309021ee in UIApplicationMain
#15 0x00001eb4 in main at main.m:14

编辑2:ObjectAlloc

Edit 2: ObjectAlloc

在ObjectAlloc中查找有问题的内存地址我找到两个匹配:

Looking up the memory address in question in ObjectAlloc I find two matches:

#    Address     Category           Creation Time      Size Responsible Library Responsible Caller
0   0x1076980   GeneralBlock-48    00:11.470       48      QuartzCore  -[CALayer setDelegate:]
1   0x1076980   CALayer            00:11.552       48      UIKit       -[UIView _createLayerWithFrame:]

正在进入#0 GeneralBlock-48:

Digging into #0 GeneralBlock-48:

#   Category        Event Type  Timestamp   Address Size    Responsible Library Responsible Caller
0   GeneralBlock-48 Malloc      00:11.470   0x1076980   48  QuartzCore  -[CALayer setDelegate:]
1   GeneralBlock-48 Free        00:11.551   0x1076980   -48 QuartzCore  -[CALayer addAnimation:forKey:]
2   CALayer         Malloc      00:11.552   0x1076980   48  UIKit   -[UIView _createLayerWithFrame:]

进入#1 CALayer:

Digging into #1 CALayer:

#   Category        Event Type  Timestamp   Address    Size Responsible Library Responsible Caller
0   GeneralBlock-48 Malloc      00:11.470   0x1076980   48  QuartzCore  -[CALayer setDelegate:]
1   GeneralBlock-48 Free        00:11.551   0x1076980   -48 QuartzCore  -[CALayer addAnimation:forKey:]
2   CALayer         Malloc      00:11.552   0x1076980   48  UIKit   -[UIView _createLayerWithFrame:]

现在看到,在#0或#1中钻得更深,揭示了完全相同的信息。我想这应该把一半的故障排除...但我仍然在损失...

Well, I see now that drilling deeper in either #0 or #1 reveals the exact same information. I suppose that should cut troubleshooting this in half...but I'm still at a loss...

推荐答案

回溯跟踪是僵尸正在消息传递的地方。这种回溯通常会提供关于导致崩溃的信息。它几乎只告诉你被过度释放的对象的类型和地址。

I believe the backtrace is just the point where the zombie is being messaged. This backtrace usually gives you zero information about what is causing the crash. It pretty much only tells you the type and the address of the object that is being over-released.

一个我经常用来跟踪过度释放的技术使用Instruments的ObjectAlloc跟踪所有保留和释放。在ObjectAlloc中找到过度释放的对象的地址,然后列出所有的retain / release调用,然后尝试使用释放来平衡每个retain。一旦找到没有保留的版本,您就会发现问题。

A technique I often use to track down over-releases like this is to use Instruments' ObjectAlloc to track all retains and releases. Find the address for the over-released object in ObjectAlloc, then list all the retain/release calls, and then try to balance each retain with a release. Once you find a release without a retain to match, You've found the problem.

这篇关于NSZombies正在吃我的应用程序的大脑!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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