【发布时间】:2011-01-22 03:16:47
【问题描述】:
我有一个特定的泄漏,我似乎无法深入挖掘,因为我的搜索总是在某些 Apple 库中结束。一些退伍军人在处理此问题方面的任何帮助将不胜感激。
这里是相关的源代码:(用注释指出泄漏)
- (void)viewDidLoad {
//[super viewDidLoad];
NSManagedObjectContext *context = [(iEatAppDelegate*)[[UIApplication sharedApplication] delegate] managedObjectContext];
addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:creator action:@selector(launchCreatorWindow)];
self.navigationItem.rightBarButtonItem = addButton;
NSFetchRequest *fetReq = [[NSFetchRequest alloc] init];
[fetReq setEntity:[NSEntityDescription entityForName:entityName inManagedObjectContext:context]];
NSError *e = nil;
NSArray *temp = [context executeFetchRequest:fetReq error:&e];
//leaking here according to performance tool
self.tableObjects = [[NSMutableArray alloc] initWithArray:temp];
if (e) {
NSLog(@"%@, %@", e, [e description]);
}
[fetReq release];
}
我尝试释放 temp,但它与 EXC_BAD_ACCESS 一起崩溃,我相信这意味着它已经自动释放。
泄漏性能工具说它是一个类别:CFArray (store-deque) 事件:Malloc 还说我的图书馆负责。这是堆栈跟踪,编号 8 是我的 viewDidLoad 帧:
0 CoreFoundation __CFAllocatorSystemAllocate
1 CoreFoundation CFAllocatorAllocate
2 CoreFoundation _CFAllocatorAllocateGC
3 CoreFoundation _CFArrayReplaceValues
4 CoreFoundation CFArrayReplaceValues
5 CoreFoundation -[__NSPlaceholderArray initWithObjects:count:]
6 CoreFoundation -[NSArray initWithArray:copyItems:]
7 CoreFoundation -[NSArray initWithArray:]
这个真的让我卡住了,非常感谢任何帮助。
【问题讨论】:
标签: iphone core-data memory-leaks