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: Jim Correia <email@hidden>
- Date: Mon, 11 Dec 2006 08:43:22 -0500
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