當最終在儀器測試我的應用程序是否泄漏,我碰到過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