我无法找到解决下面代码中内存泄漏的方法。请帮忙。
// 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];
答案 0 :(得分:2)
该代码没有泄漏。很可能发生的事情是您忘记在某个时间点[dict release]
,这意味着NSMutableDictionary
创建和引用的dict
永远不会被释放。
答案 1 :(得分:0)
我会在调用堆栈中看起来更高......你可能不会释放封装代码片段的对象。