【问题标题】:NSMutableDictionary memory leakNSMutableDictionary 内存泄漏
【发布时间】:2011-05-03 23:26:07
【问题描述】:

我找不到解决以下代码内存泄漏的方法。请帮忙。

    // 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];

【问题讨论】:

    标签: objective-c memory-management nsmutabledictionary


    【解决方案1】:

    该代码没有泄漏。很可能发生的事情是您在某些时候忘记了[dict release],这意味着dict 创建和引用的NSMutableDictionary 永远不会被释放。

    【讨论】:

    • 我有 [dict release]; on - (void)dealloc 和另一个地方,当使用它的程序循环完成时,但 Instruments Leaks 一直指向我提供的代码的泄漏...谢谢 Dave
    【解决方案2】:

    我会在调用堆栈中看起来更高...您可能没有释放封装您的代码 sn-p 的对象。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-24
      相关资源
      最近更新 更多