Sunday 3 March 2013

Debugging EXC_BAD_ACCESS in Xcode 4.2


The program receives the EXC_BAD_ACCESS signal when a message is sent to an object that has been deallocated. With the environment variable NSZombieEnabled set to YES, objects are never deallocated, but instead kept in memory as zombie objects. When a message is sent to a zombie object, execution stops at the line that would normally cause the EXC_BAD_ACCESS signal.
In Xcode 4.2, you could set environment variables by editing scheme, select the “Run XYZ.app” stage in the left panel, then select the “Arguments” tab on the right.
It’s important that you disable NSZombieEnabled once you’re done, or your application would use a tremendous amount of memory and eventually would crash.

No comments:

Post a Comment