On Wed, May 21, 2008 at 5:06 PM, Christopher Nebel <[EMAIL PROTECTED]>
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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to