Re: Core Data, using refreshObject:mergeChanges: to trim a portion of my object graph and regain memory... PLEASE HELP!!!!!!!
Re: Core Data, using refreshObject:mergeChanges: to trim a portion of my object graph and regain memory... PLEASE HELP!!!!!!!
- Subject: Re: Core Data, using refreshObject:mergeChanges: to trim a portion of my object graph and regain memory... PLEASE HELP!!!!!!!
- From: Aurélien Hugelé <email@hidden>
- Date: Mon, 11 Dec 2006 15:16:33 +0100
Thanks Jim, you're right, the objects are now correctly deallocated!
You saved my life! (or something like that :) )
Honestly i don't understand why do the objects are deallocated on the
next (after a runloop cycle) processPendingChanges... i think this
reduce Core Data usage to NSApplication only, since many Foundation
Tools do not have any runloop...Despite the fact that apple promote
the Core Data "Stack" as beeing usable even with Foundation Tools...
any idea ?
anyway, thanks for your perseverance!
Aurélien Hugelé.
On 11 déc. 06, at 14:43, Jim Correia wrote:
On Dec 11, 2006, at 3:08 AM, Aurélien Hugelé wrote:
I'm not sure, but i think saving the context has the very same
effect as processPendingChanges.
Anyway it is not sufficient.
Saving the context should cause all pending changes to be
processed. The object is deallocated on the *next* (different pass
through the event loop) process pending changes (which never
happens in your app, but would happen in a GUI app where the user
was making edits.)
I can't offer you an explanation for why this is true, only that it
appears to be true on 10.4.8.
Here are the modifications I made to your sample:
- (void)applicationDidFinishLaunching:(NSNotification *)sender {
// insert a managed object (autoreleased)
NSManagedObject* truc = [NSEntityDescription
insertNewObjectForEntityForName:@"Entity" inManagedObjectContext:
[self managedObjectContext]];
// modify it
[truc setValue:@"toto" forKey:@"attribute"];
// save so that it is not inserted anymore
[[self managedObjectContext] save:nil];
[self performSelector: @selector
(clearUndoStackAndProcessPendingChanges) withObject: nil
afterDelay: 0];
}
- (void)clearUndoStackAndProcessPendingChanges {
[[[self managedObjectContext] undoManager] removeAllActions];
[[self managedObjectContext] processPendingChanges];
}
Jim
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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