How to track down zombie object crash?

2.9k views Asked by At

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.

2

There are 2 answers

0
sanjaymathad On

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 :)

0
Duncan C On

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.