0
當我向核心數據中的提取請求添加排序描述符時,出現內存泄漏。如果我註釋掉NSSortDescriptor塊,它將在Instruments中沒有內存泄漏的情況下運行。導致內存泄漏的核心數據NSSortDescriptor
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Pools" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"game.league.id=%i",[lid intValue]];
[fetchRequest setPredicate:predicate];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"game.date" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
[sortDescriptors release];
[sortDescriptor release];
NSError *error;
NSArray *items = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
// Do Something
[fetchRequest release];
[items release];
任何想法?
那裏沒有任何自定義代碼。核心數據堆棧可能是錯誤的? – 2010-07-13 13:07:18
不太可能。爲什麼會出現泄漏,而不是您設置Core Data堆棧的位置?樂器會告訴你什麼在泄漏。將此源文件拖放到樂器中,它會向您顯示泄漏線。檢查該行的堆棧,它會告訴你哪個對象泄漏。它可能在''do something'與'game.date'相關的代碼中。 – TechZen 2010-07-13 13:34:53