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.


--Chris N.
_______________________________________________

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