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: Wade Tregaskis <email@hidden>
- Date: Mon, 01 Aug 2011 17:51:31 -0700
>> 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.
Also, if you look further, at the Exceptions section, it states that by default ARC is not exception-safe even aside from autorelease pools. You can enable it, though - and it is enabled by default for Objective-C++ - using -fobjc-arc-exceptions.
You'll note that the "Rationale" comments on those two sections specifically lay out the expected usage of exceptions: for programmer error. That they're tolerated [somewhat] in Objective-C++ is simply a nod to history for the sake of compatibility.
_______________________________________________
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