Re: Trying to understand -- please help...
Re: Trying to understand -- please help...
- Subject: Re: Trying to understand -- please help...
- From: "Sherm Pendley" <email@hidden>
- Date: Wed, 21 May 2008 17:29:17 -0400
On Wed, May 21, 2008 at 5:06 PM, Christopher Nebel <email@hidden>
wrote:
> On May 21, 2008, at 10:36 AM, Sherm Pendley wrote:
>
> [Objects] are simply released when the autorelease pool they are created
>>> in is released - which you can treat as occurring at the end of the method
>>> in which the init occurs.
>>>
>>
>> Nonsense again. The autorelease pool is emptied at the end of each
>> iteration through the event loop, and each iteration can encompass any
>> number of method calls.
>>
>
> Actually, the original raises a valid point. It's true that the
> autorelease pool is emptied each time through the main event loop. However,
> methods are free to create their own autorelease pools -- folks do this when
> they know they're going to create a bunch of short-lived objects. The point
> is, whoever called you might pop an autorelease pool as soon as your method
> returns. There's no guarantee that autoreleased stuff will be dealloc'ed as
> soon as you return, but there's also no guarantee that it won't. In other
> words, if you want to keep it after you return, retain it.
You're right, but I was simply pointing out the lifetime of the default
pool, not explaining every possible scenario involving one's own pools. The
likelihood that someone at this experience level will have Sharked their app
and arrived at a hand-created pool as the solution to a bottleneck is pretty
small, so I chose to ignore such pools for the sake of simplifying the
explanation of the default pool.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________
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