ARC的内存泄漏?

时间:2012-06-23 23:26:30

标签: objective-c automatic-ref-counting

我是Objective C的新手,我已经在Stack Overflow和Apple的网站上阅读了有关自动引用计数的几个文档,但我仍然无法弄清楚为什么“Leaks”告诉我我的代码是泄露记忆。可能需要注意的是,所有这些代码都在由NSOperationQueue启动的后台线程上运行。

例如,我有这样的事情:

NSArray *times = <receives an array of NSStrings>;
NSArray *codes = <receives an array of NSStrings>;
// these two arrays are == in length

NSMutableArray *fingerprint = [NSMutableArray array];
for (int x = 0; x < [times count]; x++) {
    long numToAdd = strtol([[codes objectAtIndex:x] cStringUsingEncoding:NSUTF8Encoding], NULL, 16);
    [fingerprint addObject:[NSNumber numberWithLong:numToAdd]];
    numToAdd = strtol([[times objectAtIndex:x] cStringUsingEncoding:NSUTF8Encoding], NULL, 16);
    [fingerprint addObject:[NSNumber numberWithLong:numToAdd]];
}

泄漏声称在分配数组的线路上存在泄漏,以及第一个对象添加的泄漏,但不是第二个。我不知道为什么会出现这些泄漏。任何帮助表示赞赏。

如果需要更多代码,请发表评论,我很乐意提供。

0 个答案:

没有答案