Re: CoreData, reset a persistent store
Re: CoreData, reset a persistent store
- Subject: Re: CoreData, reset a persistent store
- From: "I. Savant" <email@hidden>
- Date: Wed, 15 Nov 2006 13:05:03 -0500
This is why I've stepped back from the thread a bit. Until there's
actually a problem to solve, it's a waste of time and energy to
speculate.
Pierre, this is two people so far telling you to test / profile in
Shark. Of course if you're happy physically removing the store and
setting everything back up, it's definitely *a* solution. IMHO, it's
easier to just delete the objects in the store rather than removing
it entirely. Who knows - your user may have attached metadata to the
store file that he/she doesn't want removed. I really don't think
you'll run into a performance issue doing so.
--
I.S.
On Nov 15, 2006, at 12:24 PM, Marcus S. Zarra wrote:
Have you tested doing a full retrieval and deletion? When core
data retrieves the objects, they are in a faulted state. As long
as you do not touch any of the fields inside of the objects they
will remain faulted and take up a minimal amount of memory.
As others have suggested, you might be prematurely optimizing this
issue. I would suggest trying a retrieval/delete and test it with
shark to see if there is even a memory issue to solve.
Marcus S. Zarra
Zarra Studios LLC
Simply Elegant Software for OS X
www.zarrastudios.com
On Nov 15, 2006, at 9:47 AM, Elise van Looij wrote:
Op 14-nov-2006, om 17:20 heeft Pierre Chatelier het volgende
geschreven:
No, at runtime I don't think that would be a good idea. You
might want to take a look at Apple's
NSPersistentStoreCoordinator Class Reference.
That's what I did, but there is no method to clear a persistent
store.
But as far as the cache growing to gigantic proportions, I don't
think you need to worry about that.
I do worry. I don't want my cache file to take dozen of GB, even
if only a part of it is in memory (thanks to faulting).
So far, what I do is:
-lock the managed object context
-reset the managed object context to clear all pending changes
-call removePersistentStore:error on the PersistentStoreCoordinator
-remove the underlying file with NSFileManager
-call addPersistentStoreWithType:configuration:URL:options:error
on the PersistentStoreCoordinator to re-create the file
-unlock the managed object context
Sorry, I don't know enough about memory management to help you
with that. What I don't quite understand from your solution,
though, is why you want to discard all the pending changes. If you
don't want to have any pending changes, don't allow your users to
make any changes. That way you won't have to worry about throwing
them away.
Elise van Looij
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden