我收到此错误信息:诊断错误:“放发送到重新分配的对象”
message [CFString release] sent to deallocated object at 0x........
我怎样才能知道哪些字符串造成这个问题?我能弄清楚它使用调试器的哪个CFString
?
我收到此错误信息:诊断错误:“放发送到重新分配的对象”
message [CFString release] sent to deallocated object at 0x........
我怎样才能知道哪些字符串造成这个问题?我能弄清楚它使用调试器的哪个CFString
?
如果您使用的是XCode 4,请使用Zombie乐器(构建和配置文件)。发生此消息时,可以按箭头以获取字符串保留和释放的位置列表。
请参阅http://www.cocoadev.com/index.pl?NSZombieEnabled放置一个断点并回顾堆栈以查找它发生的释放声明。
在firts中,您可以尝试查找alloc/dealloc函数的代码并对其进行计数。
它已被作为“计数alloc ==计数dealloc”。
第二步,找一些建筑:
NSString *myString = [NSString stringWith...]; // Auto alloc/init with content
[myString release]; // Release before use
NSLog(@"%@", myString); // Use after release
或尝试调试与NSLog(%"retain count :%d", [myString retainCount]);
不要使用保留计数进行调试。它不会告诉你任何有用的东西:http://stackoverflow.com/questions/4636146/when-to-use-retaincount。 – 2011-04-25 08:03:21
您还可以在乐器中测试您的程序,了解内存泄漏情况并查看您获得它的位置:) – iTux 2011-05-10 00:47:31
仪器是真的有很多的帮助,THX! – CarmeloS 2011-04-27 04:03:36