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.

bullet
To find messages sent to deallocated objects
  1. 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.

  2. The Run button has four options. Hold down the Run button until the menu appears, and choose Profile.

    ../Art/xcode_profile_menu_2x.png
  3. The Instruments template window appears. Choose the Zombies template.

    ../Art/instruments_zombies_instrument_template_2x.png
  4. Click the Record button, and exercise your app until a Zombie Messaged dialog appears.

  5. Click the focus button to the right of the message text in the dialog.

    ../Art/instruments_zombie_flag_2x.png
  6. 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.

  7. 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.

When an 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.