2010-09-15 23 views
0
NSURL *xmlUrl = [[NSURL alloc] initWithString:@"http://www.xml-document.xml"]; 
NSString *converted = [[NSString alloc] initWithContentsOfURL:xmlUrl encoding:NSISOLatin1StringEncoding error:nil]; 

converted = [converted stringByReplacingOccurrencesOfString:@"&" withString:@"&"]; 
converted = [converted stringByDecodingXMLEntities]; 

最後一行佔據儀器>泄漏內存的98.3%。MWFeedParser stringByReplacingXmlEntities內存泄漏

而且它砸我的登錄窗口:

__NSAutoreleaseNoPool(): Object 0x6d10ba0 of class UIView autoreleased with no pool in place - just leaking 

爲什麼?我認爲方法之前良好的工作...

+0

對於初學者,您正在泄漏第一個字符串 - 您擁有它,但立即用下一行中的新字符串覆蓋它。如果文檔很大,請考慮不使用自動釋放和可能可變的字符串。你是在一個單獨的線程中做這個嗎? – 2010-09-15 13:50:03

回答

0

經過一些google搜索,我發現,它一定是因爲這些方法:

 [self performSelectorInBackground:@selector(load) withObject:loadingIndicator]; 
[self performSelectorInBackground:@selector(getEvents) withObject:nil]; 

所以我已經試過分配一個NSAutoReleasePool和釋放它工作完成後的方法。

現在我收到EXC_BAD_ACCESS消息。

這樣做不是在我決定在後臺運行這些方法之前發生了異常。那麼這裏有什麼問題?

+0

這是因爲我在另一個線程中創建了我的UITableView,而不是我爲獲取數據源而運行的線程。 – 2010-09-21 15:20:37