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: Fritz Anderson <email@hidden>
- Date: Sat, 30 Jul 2011 09:38:40 -0500
On 29 Jul 2011, at 10:00 PM, Kyle Sluder 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>:
> If you drain an autorelease pool that is not the top of the stack, all (unreleased) autorelease pools above it on the stack are drained (and all their objects sent appropriate release messages). If you neglect to send drain to an autorelease pool when you are finished with it (something not recommended), the pool is drained when one of the autorelease pools in which it nests is drained.
>
> This behavior has implications for exceptional conditions. If an exception occurs, and the thread suddenly transfers out of the current context, the pool associated with that context is drained. However, if that pool is not the top pool on the thread’s stack, all the pools above the drained pool are also drained (releasing all their objects in the process). The top autorelease pool on the thread’s stack then becomes the pool previously underneath the drained pool associated with the exceptional condition. Because of this behavior, exception handlers do not need to release objects that were sentautorelease. Neither is it necessary or even desirable for an exception handler to send release to its autorelease pool, unless the handler is re-raising the exception.
— F
_______________________________________________
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