• 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: Luke the Hiesterman <email@hidden>
  • Date: Wed, 19 Nov 2008 15:44:24 -0800

It's simply not true that you have "no idea" when an object will be autoreleased. If you're on the main thread, you know that it will be released at the end of the runloop, and you know that your current method will return to its caller within the current runloop. Furthermore, you know that if you call a method from your method, that it will be executed within the current runloop. Unless you're dealing with asynchronous calls, it's actually fairly easy to know if you're going to fall out of the current runloop or not.

Luke


On Nov 19, 2008, at 3:31 PM, Kyle Sluder wrote:

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

_______________________________________________

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: Chris Kane <email@hidden>
    • Re: Autorelease Question
      • From: "Kyle Sluder" <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>)
 >Re: Autorelease Question (From: "Kyle Sluder" <email@hidden>)

  • Prev by Date: RE: Outlets / IBOutlet declarations (was Re: InterfaceBuilder &Wiring Objects)
  • Next by Date: Plist to tableview
  • Previous by thread: Re: Autorelease Question
  • Next by thread: Re: Autorelease Question
  • Index(es):
    • Date
    • Thread