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 09:08:26 +0100
Thanks Jim for your help,
Unfortunately adding processPendingChanges myself does not help. I
even use removeAllActions on the undo manager just in case.
I'm not sure, but i think saving the context has the very same effect
as processPendingChanges.
Anyway it is not sufficient.
Can anybody help? based on my "too simple app" it looks like a CD
memory management bug :-o
[[[self managedObjectContext] undoManager] disableUndoRegistration];
[[[self managedObjectContext] undoManager] removeAllActions];
// [[self managedObjectContext] setUndoManager:nil];
// 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
NSError* error;
if(![[self managedObjectContext] save:&error])
NSLog(@"Error during MOC save:%@",error);
[[self managedObjectContext] processPendingChanges];
[[[self managedObjectContext] undoManager] disableUndoRegistration];
[[[self managedObjectContext] undoManager] removeAllActions];
On 8 déc. 06, at 17:16, Jim Correia wrote:
Aurélien,
I'm a huge fan of writing sample apps to test things in isolation.
In this particular case, I think your app is a little bit too
simple :-). If you had a "complete" application you'd see the
object be deallocated on the next -[NSManagedObjectContext
processPendingChanges].
On Dec 8, 2006, at 2:56 AM, Aurélien Hugelé wrote:
After I sent the email, I thought about the NSUndoManager. I did
try 2 different things:
// where the MOC is allocated
[[self managedObjectContext] setUndoManager:nil];
and I've tried [[[self managedObjectContext] undoManager]
disableUndoRegistration] too
but it doesn't help!
is disableUndoRegistration (at the very beginning of course) the
right way to "clear the undo stack"?
disableUndoRegistration is the right way to prevent registration
with the undo manager to begin with. (You should make sure all
pending changes are processed before disabling undo, do your work,
make sure pending changes are processed, then re-enabled undo
registration.)
-[NSUndoManager removeAllActions] is the way to clear the undo stack.
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