From fb4d2b07ab397f52a1c899d9c527613c66d13d2f Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 3 Dec 2024 09:35:25 +0800 Subject: [PATCH] Fix memory leaks of NSObjects on macOS if gfx device thread is disabled. (#17997) --- native/cocos/platform/mac/MacPlatform.mm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/native/cocos/platform/mac/MacPlatform.mm b/native/cocos/platform/mac/MacPlatform.mm index 722b358f2ed..4d0b0ab84df 100644 --- a/native/cocos/platform/mac/MacPlatform.mm +++ b/native/cocos/platform/mac/MacPlatform.mm @@ -79,12 +79,16 @@ of this software and associated engine source code (the "Software"), a limited, int32_t MacPlatform::loop(void) { #if CC_EDITOR - runTask(); + @autoreleasepool { + runTask(); + } return 1; #else while(!_readyToExit) { - pollEvent(); - runTask(); + @autoreleasepool { + pollEvent(); + runTask(); + } } onDestroy(); return 0; @@ -95,7 +99,9 @@ of this software and associated engine source code (the "Software"), a limited, #if defined(CC_SERVER_MODE) cocos_main(argc, argv); while (true) { - runTask(); + @autoreleasepool { + runTask(); + } } return 0; #else