mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-27 13:02:41 +08:00
fix memory leak (#10804)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user