Уважаемое сообщество.У меня очень странная утечка, которую я не могу уловить инструментами.Приложение съедает память очень быстро от 200М до 450М за один цикл удаления.Список трёх вызовов для списка объектов показывает, что проблема в NSManagedObjectContext NSFetchRequest-> processRecentChanges-> пропагатаPendingDeletesAtEndOfEvent.Объем данных невелик, текущее хранилище sqllite составляет 37 МБ, а память не освобождается после завершения процесса.
NSError *error = nil;
NSManagedObjectContext *moc = [self managedObjectContext];
NSFetchRequest *requestCarrier = [[NSFetchRequest alloc] init];
[requestCarrier setEntity:[NSEntityDescription entityForName:@"DestinationsListForSale"
inManagedObjectContext:moc]];
[requestCarrier setPredicate:[NSPredicate predicateWithFormat:@"(carrier.name == %@)",
carrierName]];
NSArray *destinationsListsForSale = [moc executeFetchRequest:requestCarrier error:&error];
if (error) NSLog(@"Failed to executeFetchRequest to data store: %@", [error localizedDescription]);
for (NSManagedObject *destinationForSale in destinationsListsForSale) [moc deleteObject:destinationForSale];
[requestCarrier release], requestCarrier = nil;
destinationsListsForSale = nil;
requestCarrier = [[NSFetchRequest alloc] init];
[requestCarrier setEntity:[NSEntityDescription entityForName:@"DestinationsListWeBuy" inManagedObjectContext:moc]];
[requestCarrier setPredicate:[NSPredicate predicateWithFormat:@"(carrier.name == %@)", carrierName]];
NSArray *destinationsListsWeBuy = [moc executeFetchRequest:requestCarrier error:&error];
if (error) NSLog(@"Failed to executeFetchRequest to data store: %@", [error localizedDescription]);
for (NSManagedObject *destinationWeBuy in destinationsListsWeBuy) [moc deleteObject:destinationWeBuy];
[requestCarrier release], requestCarrier = nil;
destinationsListsWeBuy = nil;
РЕШЕНИЕ v.1 пересобрать код для устранения проблемы
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
for (NSManagedObject *destination in destinationsList)
{
[moc deleteObject:destination];
if (x % 10 == 0) {
[moc save:&error];
if (error) NSLog(@"Failed to save to data store removePreviousDestinationsFromMainDatabaseForCarrier: %@", [error localizedDescription]);
[pool drain],pool = nil;
pool = [[NSAutoreleasePool alloc] init];
}
x++;
}