2011-04-25 63 views

回答

3

如果您使用的是XCode 4,請使用Zombie樂器(構建和配置文件)。發生此消息時,可以按箭頭以獲取字符串保留和釋放的位置列表。

+0

儀器是真的有很多的幫助,THX! – CarmeloS 2011-04-27 04:03:36

-1

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

+1

不要使用保留計數進行調試。它不會告訴你任何有用的東西:http://stackoverflow.com/questions/4636146/when-to-use-retaincount。 – 2011-04-25 08:03:21

+0

您還可以在樂器中測試您的程序,瞭解內存泄漏情況並查看您獲得它的位置:) – iTux 2011-05-10 00:47:31