• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CoreData transient attribute memory leak?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CoreData transient attribute memory leak?


  • Subject: CoreData transient attribute memory leak?
  • From: Drew Mccormack <email@hidden>
  • Date: Thu, 7 Sep 2006 12:26:47 +0200

I have discovered a memory leak in my code related to transient properties, and the refreshObject:mergeChanges: method.
In particular, if I initialize a transient property in awakeFromFetch:, like so


-(void)awakeFromFetch {
    [super awakeFromFetch];
    RetainMonitor *monitor = [RetainMonitor new];
    [self setValue:monitor forKey:@"refreshedTransient"];
    [monitor release];
}

with refreshedTransient a transient property, and then call refreshObject:mergeChanges: passing YES for the mergeChanges argument, the following sequence of events occurs:

- 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 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.


Is this a bug, or am I misunderstanding something here?

Drew

========================================
 Dr. Drew McCormack (Kmr. R153)
 Afd. Theoretische Chemie
 Faculteit Exacte Wetenschappen
 Vrije Universiteit Amsterdam
 De Boelelaan 1083
 1081 HV Amsterdam
 The Netherlands

 Email        		da.mccormack at few.vu.nl
 Web        		http://www.macanics.net
				http://www.macresearch.org
 Blog			http://www.macanics.net/blog

 Telephone      	+31 20 5987623
 Mobile        		+31 6   52678259
 Fax           		+31 20 5987629


_______________________________________________ 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
  • Follow-Ups:
    • Re: CoreData transient attribute memory leak?
      • From: Jakob Olesen <email@hidden>
  • Prev by Date: Re: New app for memory management?
  • Next by Date: Re: New app for memory management?
  • Previous by thread: RE: How to know user clicks [print] button in cocoa PDE
  • Next by thread: Re: CoreData transient attribute memory leak?
  • Index(es):
    • Date
    • Thread