Re: Autorelease/Retain/Release
Re: Autorelease/Retain/Release
- Subject: Re: Autorelease/Retain/Release
- From: mmalc crawford <email@hidden>
- Date: Tue, 24 Jul 2007 20:01:08 -0700
On Jul 24, 2007, at 7:18 PM, Tim Davis wrote:
As Charlton put it, the autorelease pool is sometimes quirky as to
when it actually gets rid of objects, so I would actually be better
off releasing it myself, and keeping the autorelease uses to things
like looping through an XML doc or creating one (in this example
anyways).
No, this is not correct.
The autorelease pool is *not* quirky as to when it actually gets rid
of objects; it sends a release message to all objects that have been
autoreleased within its scope when it is itself released. That's it.
There is no "quirkiness".
If you are using a loop, you would almost certainly be better off
releasing rather than autoreleasing any temporary objects you create
with the loop. This is explained (from the opposite perspective) here:
<http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Concepts/AutoreleasePools.html
>
(see "Guaranteeing the Foundation Ownership Policy").
mmalc
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden