Reputation: 2991
I read somewhere that when we use @autoreleasepool { }
blocks with ARC enabled, the compiler generates code to get the objc_autoreleasePoolPush()
and objc_autoreleasePoolPop()
functions called at the beginning and at the end of the block, respectively.
However, when I compile an Objective-C file with @autoreleasepool
blocks, these two functions don't get called, even with -fobjc-arc
. Instead, the compiler generates code to allocate a new NSAutoreleasePool
object (with something equivalent to [[NSAutoreleasePool alloc] init]
) at the beginning and to drain the pool (with a -drain
call) at the end of the block.
So, are the objc_autoreleasePoolPush()
and objc_autoreleasePoolPop()
functions really supposed to be called with ARC enabled? If yes, what compiler options are missing?
Upvotes: 3
Views: 1868
Reputation: 2991
objc_autoreleasePoolPush()
and objc_autoreleasePoolPop()
are really supposed to be called at the beginning and at the and of an @autoreleasepool
block, respectively, from the code generated by the compiler, starting from OSX 10.7/ iOS 5.0. The missing compiler option is -fobjc-runtime=macosx-10.7
.
And, by the way, ARC has nothing to do with all this, so that @autoreleasepool
blocks make the compiler generate calls to those two functions even with ARC not enabled.
Upvotes: 3
Reputation: 41831
What's your deployment target set to? It may need to be OSX 10.8/iOS 6 to get the newer way of doing things.
Upvotes: 2