I have a problem with Core Data and NSMutableArray. Reading this document: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdPerformance.html#//apple_ref/doc/uid/TP40003468-SW2 in the chapter "Faulting Behavior" I read: Since isEqual and hash do not cause a fault to fire, managed objects can typically be placed in collections without firing a fault.
Ok, for this reason, I understand that I can: - fetch the managedObjectContext - put all managed object into an array (the objects contains image data)
without firing a fault and waste memory (until the object is accessed for the first time), correct?
But, for some reason, Core Data is firing a fault when I try to put the result in an NSMutableArray
NSArray *fetchResults = [self.managedObjectContext executeFetchRequest:request error:&error]; //this line does'n fire a fault
self.cache = [NSMutableArray arrayWithArray:fetchResults]; //this line fires a fault
self.cache is simply a NSMutableArray. After the last line of code, I see the memory usage growing through instruments (I have 50MB of images in the DB, and the memory goes immediately from 2-3Mb to 52-53MB.
Any suggestion? Thanks
isEqual:
orhash
? – Carl Veazey