Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?
Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?
- Subject: Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?
- From: Greg Parker <email@hidden>
- Date: Mon, 1 Aug 2011 18:00:49 -0700
On Aug 1, 2011, at 5:51 PM, Wade Tregaskis wrote:
>>> Any code that throws exceptions will probably leak a few objects, since according to the ARC design doc the ABI requires not draining autorelease pools while unwinding the stack.
>>
>> Are you sure (or does ARC work differently)?
>>
>> <http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAutoreleasePools.html>:
>
> That'll need to be updated. If you look at the @autoreleasepool section of the ARC documentation, it specifically states that crossing out of one via an exception will not drain the pool. There doesn't appear to be any way, even through compiler flags, to change this.
If an autorelease pool pop is skipped by an exception, then the autorelease pool will not be drained immediately. However, it will generally be drained later, after the exception is caught and handled and some parent pool itself is drained normally.
@autoreleasepool is no different from NSAutoreleasePool here.
http://sealiesoftware.com/blog/archive/2008/09/16/objc_explain_Exceptions_and_autorelease_pools.html
(There is a bug in SnowLeopard and Lion: if an NSAutoreleasePool drain is skipped, then the pool's contents are cleaned up later as described, but the NSAutoreleasePool object itself may leak. @autoreleasepool fixes this small leak if your deployment target is Lion, because it never allocates the NSAutoreleasePool object in the first place.)
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
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