Re: Memory Management
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.