I think I might be accessing this wrong, perhaps somebody could point me in the right direction.
I have a Entry
entity, which has a one-to-many relationship with the Media
entity. The Media entity contains a data attribute called originalImage
.
The first 50 Entry
entities that this iterates through do not have any media
items in the set. After that, it slows down as it accesses the originalImage
attribute and eventually runs out of memory and quits to the home screen, without any message other than a previous memory warning in NSLog. Running this through Instruments also shows it running out of memory at this point. Here's my code:
NSFetchRequest *oldFetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *oldEntryEntity = [NSEntityDescription entityForName:@"Entry"
inManagedObjectContext:oldMOC];
[oldFetchRequest setEntity:oldEntryEntity];
[oldFetchRequest setFetchBatchSize:10];
NSArray *entrys = [oldMOC executeFetchRequest:oldFetchRequest error:nil];
for (NSInteger index = 0; index < entrys.count; ++index) {
Entry *entry = [entrys objectAtIndex:index];
NSOrderedSet *oldMediaSet = [entry valueForKey:@"media"];
for (Media *media in oldMediaSet) {
@autorelease {
[media valueForKey:@"originalImage"];
}
}
}
Removing that originalImage line means it doesn't crash, which is what makes me believe it's related to that being accessed. Perhaps the way I get the orderedSet means these items stay in memory?