How to track down zombie object crash?

一曲冷凌霜 提交于 2019-12-24 04:23:10

问题


I am having some wired crash in my iOS app and its not 100% reproducible. From crash log I can see that unrecognized selector(property accessor) is sent to object that is not of correct type (most likely zombie). Is there anyway in XCode that I can used to see if I am trying to access zombie object ?

Thanks.


回答1:


There are two ways. 1. Go to breakpoints sections on the left of XCode, down you can see an option to add exception breakpoints. 2. Click Menubar > Product > Scheme > Edit Scheme select the "Diagnostics" tab and click "Enable Zombie Objects"

Hope it helps :)




回答2:


There are several ways. You can turn on zombies by setting the "Enable Zombie Objects" checkbox to true in the diagnostics tab of your current build scheme's run item.

You can run the Zombies instrument on your app in the Instruments tool (select "profile" from the project menu, then in the resulting dialog, select the Memory group of instruments, and look for a "Zombies" instrument. This is really just the allocations tool with instruments turned on.

When you turn on zombie monitoring using either approach, the system no longer frees objects that are deallocated. instead they are marked with a special signature that indicates that they are a zombie. Then the next time you try to reference one you get an immediate, very specific crash, and the system can still tell what kind of object it was before it became a zombie, and with Instruments you can even tell where in your program it was allocated.



来源:https://stackoverflow.com/questions/20534018/how-to-track-down-zombie-object-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!