• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Autorelease Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Autorelease Question
      • From: "Michael Ash" <email@hidden>
    • Re: Autorelease Question
      • From: Luke the Hiesterman <email@hidden>
References: 
 >Autorelease Question (From: "Carmen Cerino Jr." <email@hidden>)
 >Re: Autorelease Question (From: DKJ <email@hidden>)
 >Re: Autorelease Question (From: Filip van der Meeren <email@hidden>)

  • Prev by Date: Re: NSButton ical Like
  • Next by Date: Re: Autorelease Question
  • Previous by thread: Re: Autorelease Question
  • Next by thread: Re: Autorelease Question
  • Index(es):
    • Date
    • Thread