2011-05-03 48 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

我会在调用堆栈中看起来更高...您可能不会释放封装代码片段的对象。