I am loading large amounts of data into Core Data on a background thread with a background NSManagedObjectContext
. I frequently reset this background context after it's saved in order to clear the object graph from memory. The context is also disposed of once the operation is complete.
The problem is that no matter what I do, Core Data refuses to release large chunks of data that are stored as external references. I've verified this in the Allocations
instrument. Once the app restarts the memory footprint stays extremely low as these external references are only unfaulted when accessed by the user. I need to be able to remove these BLOBS
from memory after the initial download and import since they take up too much space collectively. On average they are just html so most are less than 1MB
.
I have tried refreshObject:mergeChanges:
with the flag set to NO on pretty much everything. I've even tried reseting my main NSManagedObjectContext
too. I have plenty of autorelease pools
, there are no memory leaks, and zombies isn't enabled. How can I reduce my Core Data memory footprint when external references are initially created?
I've reviewed all of Apple's documentation and can't find anything about the life cycle of external BLOBS. I've also searched the many similar questions on this site with no solution: Core Data Import - Not releasing memory
Everything works fine after the app first reboots, but I need this first run to be stable too. Anyone else been able to successfully fault NSData BLOBS
with Core Data?