Obj-C,僵尸内存泄漏,我看不到它?

时间:2011-12-18 15:34:15

标签: iphone objective-c ios cocoa-touch

我认为我有内存泄漏,我启用了僵尸,在分析器中它突出显示了这部分代码,我已经标记了百分比。

对我来说很好看。

有什么想法吗?

    [NSThread detachNewThreadSelector:@selector(threadStartAnimating:) 
              toTarget:self withObject:nil];

    NSMutableArray *tmpArray = [[NSMutableArray alloc]init];

    if (metadata.isDirectory) {
        for (DBMetadata *file in [metadata.contents reverseObjectEnumerator]) {
            [tmpArray addObject:file.filename];  -- 44%
        }
    }

    self.itemArray = tmpArray;
    [tmpArray release];

    [self.dropboxTableView reloadSections:[NSIndexSet indexSetWithIndex:0] 
             withRowAnimation:UITableViewRowAnimationFade]; -- 55.6%

    [activityIndicator stopAnimating];

修改

在界面中: -

NSMutableArray *itemArray;

1 个答案:

答案 0 :(得分:1)

我认为如果您不使用NSAutoreleasePool,该线程会在此处产生泄漏?

-(void)threadStartAnimating
{
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        //your code.
        [pool release];
}

感谢。