2011-05-03 95 views
0

我無法找到一種方法來擺脫下面的代碼內存泄漏。請幫忙。NSMutableDictionary內存泄漏

// Data Transfer from pList and temp & dict Creation --------------------------------------------- 

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // pool is created 

//Path get the path to Data.plist 
NSString *path=[[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"]; 

//Next create the temp dictionary from the contents of the file 
NSMutableDictionary *temp=[NSMutableDictionary dictionaryWithContentsOfFile:path]; 

//Copy from temp and init dict 
dict = [[NSMutableDictionary alloc]initWithDictionary:temp]; 


[pool drain]; 

回答

2

該代碼沒有泄漏。很可能發生的事情是,你忘記在某個時間點執行[dict release],這意味着dict創建並引用的NSMutableDictionary永遠不會被髮布。

+0

我有[dict發佈]; on - (void)dealloc和另一個地方,當使用它的程序循環結束時,但Instruments Leaks保持指向我提供的代碼泄漏...感謝Dave – 2011-05-04 00:27:37

0

我會在調用堆棧中看起來更高...您可能不會釋放封裝代碼片段的對象。