Re: Autorelease question
Re: Autorelease question
- Subject: Re: Autorelease question
- From: Jens Alfke <email@hidden>
- Date: Thu, 3 Apr 2008 17:47:13 -0700
On 3 Apr '08, at 5:07 PM, Robert Claeson wrote:
The default autorelease pool is created in the <project name>.m file
of a newly created project. If you have messed around too much with
that file, you might have deleted it.
There's not a "default" autorelease pool. They form a stack, and get
pushed and popped dynamically.
It's true that the very outermost pool on the main thread is created
in main(); but hopefully nothing your app is doing dynamically will
end up using that pool, because objects autoreleased into it will hang
around until the app quits.
But usually when your app code is running, it's responding to events
or timers or other actions under the control of the runloop, so the
topmost autorelease pool is a temporary one created by the runloop for
the duration of that call (and cleaned up as soon as your code returns.)
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.
—Jens
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