在 xcode 中跟踪僵尸对象
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32252477/
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
Track a zombie object in xcode
提问by Chlebta
I'm getting this error exc_bad_access code=1 address= xcode
in my IOS app so I've tried to use the zombie tool like this :
我exc_bad_access code=1 address= xcode
在我的 IOS 应用程序中收到此错误,因此我尝试使用这样的僵尸工具:
Product->Profile->Zombies then I click on start recording (the red dot)
Product->Profile->Zombies 然后我点击开始录制(红点)
Also I've check the Enable Zombie Objects
in
此外,我已经检查Enable Zombie Objects
中
Product->Scheme->Edit scheme->Run->Diagnostics
产品->方案->编辑方案->运行->诊断
The problem is when I'm using the zombie mode and I try to simulate the error, the error is not simulated, not detected. When I run my project in normal mode, debug, the error occurs and the app crash.
问题是当我使用僵尸模式并尝试模拟错误时,错误未模拟,未检测到。当我在正常模式下运行我的项目时,调试,错误发生并且应用程序崩溃。
So what I've missed here ?
Note this is the first time I use the zombie tools. Thanks.
那么我在这里错过了什么?
请注意,这是我第一次使用僵尸工具。谢谢。
回答by DarkDust
The problem with NSZombie here is that it keeps objects alive instead of deallocating them, but turns them into special objects that complain as soon as you try to call a method on them.
NSZombie 的问题在于,它使对象保持活动状态而不是释放它们,而是将它们变成特殊对象,一旦您尝试对它们调用方法就会抱怨。
However, if you have some code like a block that just tries to access an instance variable(without calling a method on that object), this will now succeed as the object's memory region is now still available.
但是,如果您有一些代码,例如只是尝试访问实例变量(而不调用该对象的方法)的块,那么现在这将成功,因为对象的内存区域现在仍然可用。
If you haven't done so already, simply try running your code in the normal debugger without NSZombie as that should tell you where the crash happens in the stack trace.
如果您还没有这样做,只需尝试在没有 NSZombie 的普通调试器中运行您的代码,因为这应该会告诉您在堆栈跟踪中崩溃发生的位置。