fix memory leak (#10804)

This commit is contained in:
李吉林
2022-04-20 14:43:02 +08:00
committed by GitHub
parent 3da31ad481
commit 3374c7e41c
23 changed files with 214 additions and 68 deletions
+23 -22
View File
@@ -44,6 +44,12 @@
#if CC_USE_SOCKET
#include "cocos/network/WebSocket.h"
#endif
#if CC_USE_DRAGONBONES
#include "editor-support/dragonbones-creator-support/ArmatureCacheMgr.h"
#endif
#if CC_USE_SPINE
#include "editor-support/spine-creator-support/SkeletonCacheMgr.h"
#endif
#include "application/ApplicationManager.h"
#include "application/BaseApplication.h"
@@ -100,22 +106,28 @@ Engine::~Engine() {
AudioEngine::end();
#endif
Root::getInstance()->getPipeline()->destroy();
#if CC_USE_DRAGONBONES
dragonBones::ArmatureCacheMgr::destroyInstance();
#endif
#if CC_USE_SPINE
spine::SkeletonCacheMgr::destroyInstance();
#endif
network::HttpClient::destroyInstance();
EventDispatcher::destroy();
se::ScriptEngine::destroyInstance();
ProgramLib::destroyInstance();
BuiltinResMgr::destroyInstance();
gfx::DeviceManager::destroy();
CCObject::deferredDestroy();
BasePlatform *platform = BasePlatform::getPlatform();
platform->setHandleEventCallback(nullptr);
Root::getInstance()->getPipeline()->destroy();
CC_PROFILER_DESTROY;
DebugRenderer::destroyInstance();
FreeTypeFontFace::destroyFreeType();
cc::EventDispatcher::destroy();
FileUtils::destroyInstance();
se::ScriptEngine::getInstance()->cleanup();
se::ScriptEngine::destroyInstance();
gfx::DeviceManager::destroy();
CCObject::deferredDestroy();
}
int32_t Engine::init() {
@@ -154,12 +166,6 @@ int Engine::restart() {
}
void Engine::close() { // NOLINT
if (cc::EventDispatcher::initialized()) {
cc::EventDispatcher::dispatchCloseEvent();
}
auto *scriptEngine = se::ScriptEngine::getInstance();
cc::DeferredReleasePool::clear();
#if CC_USE_AUDIO
cc::AudioEngine::stopAll();
@@ -167,16 +173,11 @@ void Engine::close() { // NOLINT
//#if CC_USE_SOCKET
// cc::network::WebSocket::closeAllConnections();
//#endif
cc::network::HttpClient::destroyInstance();
_scheduler->removeAllFunctionsToBePerformedInCocosThread();
_scheduler->unscheduleAll();
scriptEngine->cleanup();
cc::EventDispatcher::destroy();
// exit
exit(0);
BasePlatform *platform = BasePlatform::getPlatform();
platform->setHandleEventCallback(nullptr);
}
uint Engine::getTotalFrames() const {