0

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?

jscs
  • 63,694
  • 13
  • 151
  • 195
CarmeloS
  • 7,868
  • 8
  • 56
  • 103

3 Answers3

3

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.

Kendall Helmstetter Gelner
  • 74,769
  • 26
  • 128
  • 150
1

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.

David Neiss
  • 8,161
  • 2
  • 20
  • 21
-1

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]);

iTux
  • 1,946
  • 1
  • 16
  • 20
  • 1
    Don't debug using retain count. It doesn't tell you anything useful: http://stackoverflow.com/questions/4636146/when-to-use-retaincount. – jscs Apr 25 '11 at 08:03
  • You also test your program in Instruments, for memory leak and see where you get it :) – iTux May 10 '11 at 00:47