• 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
Re: Memory Management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Management


  • Subject: Re: Memory Management
  • From: Michael Tsai <email@hidden>
  • Date: Tue, 29 Jul 2003 23:24:22 -0400

On Tuesday, July 29, 2003, at 01:05 PM, Jonathan E. Jackel wrote:

Perhaps I've missed some crucial point, but if an object is concerned that
someone might access one of its variables just before the object dies and
releases its ivars, and the object always gets to make a deathbed bequest
(via -dealloc), then autoreleasing ivars in -dealloc (rather than simply
releasing them) would solve the problem (if you think there is one) at a
fraction of the cost of using [[retain] autorelease] in every accessor.
Less code, fewer retains, fewer autoreleases.

Doing the autorelease in -dealloc doesn't have the same effect as doing it in the accessor, because the autorelease "scopes" may be different. For instance:

myFoo = [bar foo];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[bar release]; // suppose this causes [bar dealloc]
[pool release];
// myFoo may not be valid here.

--
Michael Tsai <http://www.c-command.com>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >RE: Memory Management (From: "Jonathan E. Jackel" <email@hidden>)

  • Prev by Date: Re: Why is sound:didFinishPlaying: only called once?
  • Next by Date: An error occurring early in runtime (Jaguar)
  • Previous by thread: RE: Memory Management
  • Next by thread: Re: Memory Management
  • Index(es):
    • Date
    • Thread