Re: CoreData transient attribute memory leak?
Re: CoreData transient attribute memory leak?
- Subject: Re: CoreData transient attribute memory leak?
- From: Drew McCormack <email@hidden>
- Date: Thu, 7 Sep 2006 22:34:42 +0200
Hi Jakob,
Thanks for the insights.
I don't know if you found a memory leak or not, but Core Data has a
lot going on behind the scenes. Are you sure your object is not
being retained by the undo manager or "change management" or
something?
I have tried clearing the undo queue to see if that was it, but the
objects are not deallocated.
Try calling [processPendingChanges] and flushing the undo manager,
see if that makes a difference.
I just tried that (thanks for the tip), but no dice I'm afraid.
I see two problems:
- the first is that I can't seem to initialize a transient
property in awakeFromFetch, without the change getting clobbered.
Given this is one of the main uses of awakeFromFetch, I think it
is a problem.
- the second is that when my change is clobbered, CD doesn't even
clean up nicely, leading to a memory leak.
If you are using [refreshObject:mergeChanges:YES], don't bother
setting transient properties in [awakeFromFetch].
It doesn't work. I assume you are working with multiple contexts
since you need to merge changes. In that scenario, you cannot use
transient properties the way they are being used in the
documentation and examples.
Actually, I only have one context, but I have fetched properties, and
to refresh them I need this method. I need to use YES, because I
don't want to lose changes in the object that are not yet in the store.
It seems to me that a single awakeFromFetch method is not entirely
adequate, because there are different types of fetches. When the
object is first fetched from the store, you need awakeFromFetch to
set transients. But when a refresh occurs, you don't want to set
transients. Two quite different circumstances. Seems to me that an
awakeFromRefresh may not be a bad idea.
Consider using a plain old instance variable.
Good idea. I'll see how I go with that.
Transient properties can still be useful, but it takes a bit more
work, see http://www.2pi.dk/tech/cocoa/transient_properties.html
Thanks, I had seen your page; it was very helpful!
Drew
---------------------------------------------------------
Drew McCormack
www.macanics.net
_______________________________________________
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