When your iPhone app crashes with ‘BAD ACCESS’ you’re in trouble – a memory bug where you tried to call a method on a object that was already deleted. Instruments has support for NSZombie – a feature that makes it easy to find the source of the bug by showing you a full history of every alloc, retain, release, and autorelease of the object that caused the crash! Wow. Here’s how:
Basic steps are:
- Run in Performance tool ‘Object Allocations’
- Stop running and set options on ObjAllocations instrument: ‘Enable NSZombie’ Detection and ‘Record Reference Counts’
- Re-run from instruments, when it crashes, click the arrow in the popup zombie dialog
- Open up the stack trace view and see the full memory history of the problem object
- Wow, how awesome is that?
- If you love this post, do me a favor and check out our Free app Focus for Facebook
- You might also like my memory management tutorial and other posts under ‘App Development’.
Here’s a link to the demo program: ZombieDebug Demo Project. The code we’re looking at in the video is: