Re: CoreData transient attribute memory leak?
Re: CoreData transient attribute memory leak?
- Subject: Re: CoreData transient attribute memory leak?
- From: Jakob Olesen <email@hidden>
- Date: Thu, 7 Sep 2006 19:28:02 +0200
On 07/09/2006, at 12.26, Drew Mccormack wrote:
- My NSManagedObject is recreated from the persistent store, with
nil for the refreshedTransient transient property.
- awakeFromFetch is called, a new RetainMonitor object created, and
the refreshedTransient property set.
- After leaving awakeFromFetch, the old RetainMonitor is reinstated
as the value for the refreshedTransient transient property,
effectively overriding my setValue:forKey:
- the new RetainMonitor --- which was created in awakeFromFetch
--- is not released, and a memory leak arises
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?
Try calling [processPendingChanges] and flushing the undo manager,
see if that makes a difference.
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.
Consider using a plain old instance variable.
Transient properties can still be useful, but it takes a bit more
work, see http://www.2pi.dk/tech/cocoa/transient_properties.html
_______________________________________________
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