diff --git a/cocos/base/CCAutoreleasePool.cpp b/cocos/base/CCAutoreleasePool.cpp index edf40f668e..e3a600244b 100644 --- a/cocos/base/CCAutoreleasePool.cpp +++ b/cocos/base/CCAutoreleasePool.cpp @@ -65,11 +65,12 @@ void AutoreleasePool::clear() #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) _isClearing = true; #endif - for (const auto &obj : _managedObjectArray) + std::vector releasings; + releasings.swap(_managedObjectArray); + for (const auto &obj : releasings) { obj->release(); } - _managedObjectArray.clear(); #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) _isClearing = false; #endif