• 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: nested autorelease pools?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: nested autorelease pools?
      • From: John Stiles <email@hidden>
References: 
 >nested autorelease pools? (From: "Brian O'Brien" <email@hidden>)
 >Re: nested autorelease pools? (From: j o a r <email@hidden>)
 >Re: nested autorelease pools? (From: John Stiles <email@hidden>)

  • Prev by Date: Re: nested autorelease pools?
  • Next by Date: copyWithZone?
  • Previous by thread: Re: nested autorelease pools?
  • Next by thread: Re: nested autorelease pools?
  • Index(es):
    • Date
    • Thread