开发者

NSMutableDictionary memory leak

开发者 https://www.devze.com 2023-03-02 20:25 出处:网络
I can\'t find a way to get rid of a memory leak on the code below. Please help. // Data Transfer from pList and temp & dict Creation---------------------------------------------

I can't find a way to get rid of a memory leak on the code below. Please help.

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

NSAutoreleasePool开发者_JAVA百科 *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];


There is no leak in that code. Quite possible what's going on is that you're forgetting to do [dict release] at some point, which means that the NSMutableDictionary created and referenced by dict is never getting released.


I would look higher in the call stack...you're probably not deallocating the object encapsulating your code snippet.

0

精彩评论

暂无评论...
验证码 换一张
取 消