← Introduction.

Changing our course →

 

Debugging memory management problems with NSZombieEnabled

Recently had an EXEC_BAD_ACCES issue, so decided to google, to find what people do in such cases, and found NSZombieEnabled. This thing is great. It helps very much. iPhone development guide says:

To activate the NSZombieEnabled facility in your application: Choose Project > Edit Active Executable to open the executable Info window. Click Arguments. Click the add (+) button in the “Variables to be set in the environment” section. Enter NSZombieEnabled in the Name column and YES in the Value column. Make sure that the checkmark for the NSZombieEnabled entry is selected.

and that's all you have to do. When this variable is set to YES, and you're trying to dealloc anything, runtime changes it's class name to _NSZombie dynamically and memory is not marked as free. So you have something like a repository of deallocated objects, and _NSZombie is watching for all dealocated objects. Everytime you're trying to send a message to a Zombie your console is populated with new message like this:

2009-12-27 11:41:22.476 App[1982:20b] *** -[CFString compare:]: message sent to deallocated instance 0x3da1e30

and it's quit descriptive as you can see. So from now I'll use this feature wherever needed. It's cool.

...

Blog posts that helped me much:

http://www.iphonedevsdk.com/forum/iphone-sdk-development/9781-trouble-setting-nszombieenabled.html http://cocoa-nut.de/?p=16

Comments

Leave a reply »

 
Leave a Reply
 
 
 
 
 
 
Twitter (@ExtraVertex)
Twitter ( we are following )
Blank column :-)