Finding Messages Sent to Deallocated Objects
Find messages sent to deallocated objects using the Zombies template in Instruments. A message sent to a deallocated object (zombie) can cause your app to crash.
Open your project in Xcode. Under most circumstances, you will have better results finding messages sent to Zombies if you open your app and Instruments from within Xcode.
The Run button has four options. Hold down the Run button until the menu appears, and choose Profile.
The Instruments template window appears. Choose the Zombies template.
Click the Record button, and exercise your app until a Zombie Messaged dialog appears.
Click the focus button to the right of the message text in the dialog.
Open the Extended Detail inspector in the sidebar pane, and double-click the Zombie entry in the Event Type column of the object history table.
Double-click the responsible caller in the Stack Trace section of the Extended Detail inspector to display the responsible code.
The Instruments Zombies template opens the Allocations instrument and also makes a significant change to your environment. The Zombies template enables the debugging environment variable
NSZombieEnabled=YES which causes all Objective-C objects to be turned into zombie objects instead of being freed after completing their
-dealloc method. It substitutes an object of type
NSZombie for objects that are released to a reference count of zero. This results in large persistent memory growth while running with this template.
NSZombie object is messaged, a Zombie Messaged dialog appears. Clicking the focus button to the right of the message in the Zombie Messaged dialog displays the complete memory history of the overreleased object.
Note that the Zombie Messaged dialog has a point at the top, aligned with a purple triangle in the timeline. If the Zombie Messaged dialog is no longer visible and you want to see it again, click the purple triangle.