当最终在仪器测试我的应用程序是否泄漏,我碰到过2个奇数泄漏:奇CoreData内存泄漏
泄露的对象:_PFArray,#:1地址:0x2a11c0尺寸:32个字节负责图书馆:CoreData负责任的框架: newFetchedRowsForFetchPlan_MT
而且
泄露的对象:malloc的16个字节,#:1地址:0x24d6b0尺寸:16个字节负责图书馆:CoreData负责框架:newFetchedRowsForFetchPlan_MT
堆栈跟踪˚F或者这两个泄漏点指向:
records = [[self.managedObjectContext executeFetchRequest:request error:&error] retain];
在CoreData Fetch中。
而且
[self.window makeKeyAndVisible];
什么是这些泄漏?我从来没有见过他们。当我构建和分析时,它们不会弹出。有人有任何建议吗?
谢谢!
编辑:
这里是记录阵列周围的代码。记录只是在.h中声明的NSarray。
/*
Fetch existing events.
Create a fetch request; find the Event entity and assign it to the request; add a sort descriptor; then execute the fetch.
*/
marblebeingdragged=YES;
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Child" inManagedObjectContext:_managedObjectContext];
[request setEntity:entity];
// Order the events by creation date, most recent first.
NSSortDescriptor *nameDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:NO];
NSSortDescriptor *prizeDescriptor = [[NSSortDescriptor alloc] initWithKey:@"prize" ascending:NO];
NSSortDescriptor *neededDescriptor = [[NSSortDescriptor alloc] initWithKey:@"marblesneeded" ascending:NO];
NSSortDescriptor *colorDescriptor = [[NSSortDescriptor alloc] initWithKey:@"color" ascending:NO];
NSSortDescriptor *reachedDiscriptor = [[NSSortDescriptor alloc] initWithKey:@"prizereached" ascending:NO];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:nameDescriptor,prizeDescriptor,neededDescriptor,colorDescriptor, nil];
[request setSortDescriptors:sortDescriptors];
[nameDescriptor release];
[colorDescriptor release];
[prizeDescriptor release];
[neededDescriptor release];
[reachedDiscriptor release];
[sortDescriptors release];
// Execute the fetch -- create a copy of the result.
NSError *error = nil;
records = [[self.managedObjectContext executeFetchRequest:request error:&error] retain];
你释放保留在完成后? – whitelionV 2012-02-15 23:51:55
@whitelionV我在我的MainViewController的dealloc方法中释放记录。 – 2012-02-16 00:18:38
我认为你不必“保留”取得的结果。 – Kjuly 2012-02-16 00:53:32