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,095
  • 13
  • 148
  • 192
CarmeloS
  • 7,658
  • 6
  • 54
  • 102

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,088
  • 26
  • 126
  • 148
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.

DavidN
  • 8,071
  • 2
  • 18
  • 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,806
  • 1
  • 15
  • 18
  • 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