MeloS
MeloS

Reputation: 7938

Diagnosing error: "release sent to deallocated object"

I received this error message:

message [CFString release] sent to deallocated object at 0x........

How can I know which string caused this problem? Can I figure out which CFString it is using the debugger?

Upvotes: 0

Views: 260

Answers (3)

iTux
iTux

Reputation: 2096

At firts, you can try lookup your code for alloc/dealloc functions, and count it.
It's has been as "count alloc == count dealloc".
The second step, look for some construction:

NSString *myString = [NSString stringWith...]; // Auto alloc/init with content
[myString release]; // Release before use
NSLog(@"%@", myString); // Use after release

Or try debug with NSLog(%"retain count :%d", [myString retainCount]);

Upvotes: -1

David Neiss
David Neiss

Reputation: 8237

See http://www.cocoadev.com/index.pl?NSZombieEnabled to put in a breakpoint and look back up the stack to find release statement where it occurred.

Upvotes: 1

If you are using XCode 4, use the Zombie instrument (Build and Profile). When this message occurs, you can press the arrow to get a list of everywhere the string was retained and released.

Upvotes: 3

Related Questions