Coming up towards the end of developing an iPhone application and I\'m wondering just how bad is it to use autorelease when developing for the iphone. I\'m faced with some fairl
More important than the autorelease or manual-release choice is how often you alloc
and dealloc
your NSAutoreleasePool
s. Since most of the Cocoa frameworks use autorelease
liberally, you need to have a proper pool draining strategy. Once that is in place, the choice of whether to release
or autorelease
becomes much less an issue.
That being said, the only areas you should worry about are tight loops--allocate and release an NSAutoreleasePool
every few iterations for best results; and when you have spawned another NSThread
that doesn't have a Runloop--create a pool and drain it every so often becomes idle. Since most applications only allocate a small amount of data per event, UIKit
's strategy of allocating the pool before the event is dispatched and releasing it after the dispatch returns works very well.