NSZombieEnabled does not work

You have a plain old crash. EXC_BAD_ACCESS means that your application has tried to access a memory address that is invalid. While the most typical reason for this in a non-GC'd objective-c application is messaging an object after deallocation, something that Zombie Mode detects, this particular crash can happen any number of other ways (as demonstrated).

Since your application is crashing, you should have a backtrace. You need to post that backtrace here for any of us to be able to help you further.

As Brad said, run your application with debugging enabled. In Xcode, you'll find the "Run/Debug" menu item under the "Run" menu. Use that one. When your application crashes, you should see a stack trace in the upper left corner of the debugger window.

No, really, they do show up in the debugger. A picture is worth 1,000 words. alt text
(source: friday.com)


"EXC_BAD_ACCESS" is not necessarily related to a zombie instance. It can be linked an access to an undefined reference, like a local variable.

NSArray *array;
[array objectAtIndex:0]; // <- Will throw an error

Edit: NSZombie flag will only help you to solve the "EXC_BAD_ACCESS" triggered by the use of a de-allocated instance.

In order to solve the bugs, you have to use the crash backtrace to pinpoint the location that is wrong. Then, go backward into your code and check every assignment and allocations.


i don't understand how the answer to this question really answers the question..

i am asking myself the same thing. using xcode4 i have enabled NSZobmieEnabled = YES to halt when i access an object that has been released, instead of crashing with EXC_BAD_ACCESS - which is very helpful.

the question at hand was:

"When I set NSZombieEnabled = Yes nothing is written to the console. How can I fix this...".

simple and straight forward.

i am experiencing the same issue. xcode halts with the debugger but the console does not produce any message. i would expect something along the lines of:

"message sent to deallocated instance...".


Also make sure you initialize all pointers to nil before using them!

If you use a pointer without initializing it to nil or any other object, you are propably going to end up accessing memory which isn't yours.

For example the following code will also give an EXC_BAD_ACCESS which is not traceable using the NSZombieEnabled flag caused by the last line.

RecordingLocation* closest;

//find the closest recording location
for (...)
{
    //try to find the closest object...
    //suppose we don't find anything so closest is never set.
}

if (closest!=nil)
    NSLog(@"Closest: %f,%f",closest.x,closest.y);