Re: nested autorelease pools?
Re: nested autorelease pools?
- Subject: Re: nested autorelease pools?
- From: j o a r <email@hidden>
- Date: Tue, 1 Nov 2005 22:56:45 +0100
On 1 nov 2005, at 22.36, John Stiles wrote:
I'm no expert here, but I suspect if we have a simple NSThread
that's used for one purpose, we can create an NSAutoreleasePool as
it's initialized and release the autorelease pool as the thread is
dealloced, and everything will work. I can't see how that could be
a problem.
As threads in general have one entry point, and one exit point, I'm
also not sure what the point of that non-standard, rule-breaking,
exercise would be? The simple pattern of bracketing the method you
run with your thread works well for this, don't you agree?
I think the real reasons behind this warning in the documentation
are stacked NSAutoreleasePools.
Yes, and the current autorelease pool is found by walking up the
stack. Now, if you create the autorelease pool outside of the context
where it's going to be used - how would it be found when an object is
autoreleased?
That said, I'm also no expert on this - and could be horribly,
horribly wrong on all accounts.
It would in any case be very interesting to learn more on the topic!
Perhaps autorelease pools shouldn't be objects at all, but rather
some sort of ObjC language construct? Something similar to the new
syntax for exception handling:
@AutoreleasePool
{
// Stuff
}
And if you're in a tight loop and need to drain the pool every now
and then:
@AutoreleasePool
{
if (SomeCondition)
{
@DrainPool
}
}
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden