Re: Core Data caching very large property values in 10.6
Re: Core Data caching very large property values in 10.6
- Subject: Re: Core Data caching very large property values in 10.6
- From: Quincey Morris <email@hidden>
- Date: Tue, 20 Jul 2010 16:00:54 -0700
On Jul 20, 2010, at 08:03, Keary Suska wrote:
> On Jul 19, 2010, at 5:47 PM, Quincey Morris wrote:
>
>> AFAICT, this is telling me that Core Data has itself cached the NSData object in a "row cache". That's very bad news, because it seems to persist in there indefinitely, until the managed object context is finally disposed of (which I can't do in the middle of the import).
>
> Why not? Managed object contexts are very cheap to create, so implementing a create-save-destroy loop shouldn't have a negative impact. But if you need some other data to "persist" in the context throughout the import process unchanged, that would be an issue, but may be solved by factoring it out to its own MOC.
>
>> Does anyone know of a way to empty or disable the row cache, or can anyone provide a better insight into what's going wrong?
>
> Barring the issue I mention above, have you tried calling -reset on the context? If anything, I would expect it to purge caches, but there's nothing to back that up...
Thanks, that helped, actually.
I had already considered both those solutions and too quickly rejected them because there were other objects that needed to persist for part or all of the import process. But you made me rethink it, and I realized that it wouldn't be extremely difficult to re-architect the processing so that the more persistent objects were fetched when needed. (Previously I had been doing for-loops over sets of Image objects that were in a to-many relationship with a parent object. Avoiding those loops was irritating but not too hard.)
Once I made that change, resetting the managed contexts worked like a charm.
Still, the Core Data API could seriously use a way of managing (at least resetting) just the caches and/or property values. I note that some of the more recent API additions give this level of control at the fetch stage (fetching only specific properties, for example) which provide an initial level of control, but once things are in memory there are no API strategies whatsoever, beyond the overly coarse 'reset'.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden