diff --git a/arc.mm b/arc.mm index 459a3fb8..899b7e15 100644 --- a/arc.mm +++ b/arc.mm @@ -552,7 +552,11 @@ static inline void release(id obj) static inline void initAutorelease(void) { - if (Nil == AutoreleasePool) + // The pool implementation is chosen once. A pool is pushed and popped + // through whichever one is in force, so a later switch would pop through + // the implementation that did not push. + static BOOL chosen; + if (!chosen) { AutoreleasePool = objc_getClass("NSAutoreleasePool"); if (Nil == AutoreleasePool) @@ -574,6 +578,7 @@ static inline void initAutorelease(void) SELECTOR(addObject:)); } } + chosen = YES; } }