Re: Autorelease Question
Re: Autorelease Question
- Subject: Re: Autorelease Question
- From: "Kyle Sluder" <email@hidden>
- Date: Wed, 19 Nov 2008 18:31:51 -0500
On Wed, Nov 19, 2008 at 6:17 PM, Filip van der Meeren
<email@hidden> wrote:
> If you wait until the end of your method to autorelease the object, you are
> leaving a whole range of possible memoryleaks open, since every call you
> make between the allocation and release is a call that might throw an
> exception (and we all know Objective-C uses memoryjumps from C).
Gah! You have no idea when an autoreleased object is going to be
released. What if a method call you make in between autoreleasing the
object and really not needing it anymore hits the top of the runloop?
Boom, your autoreleased object is gone. As the documentation states,
only use autorelease to signal that you no longer need an object.
As for exceptions, that's why we have @finally blocks. Though since
exceptions in Cocoa are supposed to be reserved for programmer errors,
I would not worry all that much about exceptions and memory leaks.
--Kyle Sluder
_______________________________________________
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