• 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: Chris Suter <email@hidden>
  • Date: Fri, 4 Apr 2008 12:00:55 +1100


On 04/04/2008, at 11:47 AM, Jens Alfke wrote:

It's true that the very outermost pool on the main thread is created in main();

I don't think that's normally the case. For a Cocoa application created by the Xcode template, it won't create an autorelease pool for you. Obviously, there won't be one created for you in the template for a Carbon application.


I suspect the reason for the observed difference reported in the original e-mail was because the code either wasn't running in the Carbon application, or was running as part of the event loop—I believe that an autorelease pool will be created for Carbon event loops.

To answer the original question: I don't think you can tell whether there's an autorelease pool active. But it doesn't matter: if you're doing anything that could autorelease objects, and there might not be a pool already, create your own by calling [NSAutoreleasePool new] beforehand and [pool drain] afterwards.

I think you mean [pool release], not [pool drain].

- Chris

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >Autorelease question (From: Dmitry Markman <email@hidden>)
 >Re: Autorelease question (From: Robert Claeson <email@hidden>)
 >Re: Autorelease question (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Autorelease question
  • Next by Date: NSCondition easter-egg hunt
  • Previous by thread: Re: Autorelease question
  • Next by thread: Re: Autorelease question
  • Index(es):
    • Date
    • Thread