Re: do i need to create autorelease pool?
Re: do i need to create autorelease pool?
- Subject: Re: do i need to create autorelease pool?
- From: Peter N Lewis <email@hidden>
- Date: Wed, 25 Feb 2009 14:00:57 +0900
I know what autorelease pools are and how they work so my question
isn't about that.
In my iPhone app I create a NSTimer to run at 60fps, in it I update
a bunch of stuff and draw opengl.
Currently I have:
-(void) timerLoop {
// create autorelease pool in case anything needs it
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
<do all update stuff here and render>
// release pool
[pool release];
}
Do I need this autorelease pool here or does UIApplicationMain
manage that for every call of timerLoop?
No, you don't need an auto release pool, the run loop handles that:
From the NSAutoreleasePool doicumentation:
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.
Enjoy,
Peter.
--
Run macros from your iPhone with Keyboard Maestro Control!
or take a break with Aragom Space War for your iPhone
Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
Aragom Space War <http://www.stairways.com/iphone/aragom> Don't get killed!
<http://www.stairways.com/> <http://download.stairways.com/>
_______________________________________________
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