• 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: do i need to create autorelease pool?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: do i need to create autorelease pool?


  • Subject: Re: do i need to create autorelease pool?
  • From: Michael Ash <email@hidden>
  • Date: Wed, 25 Feb 2009 11:44:30 -0500

On Wed, Feb 25, 2009 at 12:00 AM, Peter N Lewis <email@hidden> wrote:
>> The Application Kit creates an autorelease pool on the main thread at the
>> beginning of every cycle of the event loop, and drains it at the end,
>> thereby releasing any autoreleased objects generated while processing an
>> event.
>
> This is assuming iPhone or Leopard, I believe the NSAutoreleasePool creation
> was required for older versions of Mac OS X.

The semantics haven't changed on Leopard as far as I know. The above
has been the case forever: pools are created and destroyed on
*events*, but not timers. If you simply run a timer forever and never
process events, your memory usage will grow without limit. A pool
exists, so you don't explicitly leak, but the pool is only drained
when an event arrives. If you're going to be running something in
timers or other non-event sources, you'll want to post a fake event to
the main event loop from time to time (or just after every action you
take) to force the pool to drain.

I have *no* idea how much of that, if any, applies to the iPhone. In
any case if you're processing events on a regular basis as well then
you don't have to worry about anything.

Mike
_______________________________________________

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: do i need to create autorelease pool?
      • From: Peter N Lewis <email@hidden>
    • Re: do i need to create autorelease pool?
      • From: Memo Akten <email@hidden>
References: 
 >do i need to create autorelease pool? (From: Memo Akten <email@hidden>)

  • Prev by Date: Re: Adding text to NSImage using lockFocus/unlockFocus not working
  • Next by Date: Gamma problem (?) with CIFilter output
  • Previous by thread: Re: do i need to create autorelease pool?
  • Next by thread: Re: do i need to create autorelease pool?
  • Index(es):
    • Date
    • Thread