Today while working on an iPhone project , I was just about to commit an code which displays a bar graph, and ended up finding a crash with the following error:

objc[<pid>]:FREED(id): message release sent to freed object="<memory_address>"
Double Release Of Cocoa Objects

Double Release Of Cocoa Objects

After searching through my code, I couldn’t figure out where I was doubly releasing the object. Googling up, I found an article which helped introduce me to a few really good environment variables I could set that would allow me to identify where I was creating this problem. Here are the environment variables:

  • NSZombieEnabled
  • MallocStackLogging

With these two environment variables are set to “YES” in your executable’s Arguments tab, you then have the ability to figure out where you’re doubly releasing an object’s memory using in gdb:

shell malloc_history <pid> <memory_address>

(Note: To set these environment variables, double-click the executable in Xcode’s Executable’s group, click the Arguments tab and then add the variables.) And there you have it.)

About Me: Anish Kumar:
Mac OS X software development is my bread winner with over 6 years of experience. Expertise in Color Management, TWAIN Scanner drivers on Mac OS X, Photoshop Filter and Import Plugin development on Mac OS X, iPhone. As an hobby I love to work on PHP, Flex, AIR, Photoshop. Check the 'About' page for more.