I’m storing images in a Core Data database. More specifically, I’m using the external store function in iOS 5 Core Data so the images are actually saved outside of the database to disk, but for this scenario I don’t think that makes a difference. Here’s the issue:
I take some photos and write them to a Photo entity. As I take and save each photo, I can see my memory usage go up each time. I was under the impression that Core Data would fault the unused Photo entities when they weren’t necessary but this doesn’t seem to be happening. Is there a way to make Core Data flush the cache or cause my entities to become faults? Eventually I hit memory warnings and the app crashes.
You need to use the refreshObject:mergeChanges method of your NSManagedObjectContext to turn realized objects into faults.
See apple documentation Here