[v3.6.0] Fix memory leaks (#12185)

This commit is contained in:
James Chen
2022-07-26 18:01:53 +08:00
committed by GitHub
parent 79f2b97827
commit d553ce2bdb
4 changed files with 15 additions and 5 deletions
@@ -585,8 +585,12 @@ bool ScriptEngine::init(v8::Isolate *isolate) {
_context.Reset(_isolate, context);
_context.Get(isolate)->Enter();
} else {
static v8::ArrayBuffer::Allocator *arrayBufferAllocator{nullptr};
if (arrayBufferAllocator == nullptr) {
arrayBufferAllocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator();
}
v8::Isolate::CreateParams createParams;
createParams.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator();
createParams.array_buffer_allocator = arrayBufferAllocator;
_isolate = v8::Isolate::New(createParams);
v8::HandleScope hs(_isolate);
_context.Reset(_isolate, v8::Context::New(_isolate));
@@ -1,7 +1,7 @@
#include "DragonBones.h"
#include "../armature/Armature.h"
#include "../animation/WorldClock.h"
#include "../animation/Animation.h"
#include "../animation/WorldClock.h"
#include "../armature/Armature.h"
#include "../event/EventObject.h"
#include "../event/IEventDispatcher.h"
@@ -28,6 +28,7 @@ DragonBones::~DragonBones() {
}
_clock = nullptr;
delete _eventManager;
_eventManager = nullptr;
}
@@ -47,7 +47,9 @@ PlanarShadowQueue::PlanarShadowQueue(RenderPipeline *pipeline)
_instancedQueue = ccnew RenderInstancedQueue;
}
PlanarShadowQueue::~PlanarShadowQueue() = default;
PlanarShadowQueue::~PlanarShadowQueue() {
destroy();
}
void PlanarShadowQueue::gatherShadowPasses(scene::Camera *camera, gfx::CommandBuffer *cmdBuffer) {
clear();
@@ -138,7 +140,10 @@ void PlanarShadowQueue::recordCommandBuffer(gfx::Device *device, gfx::RenderPass
}
void PlanarShadowQueue::destroy() {
_pipeline = nullptr;
CC_SAFE_DELETE(_instancedQueue);
_castModels.clear();
_pendingModels.clear();
}
} // namespace pipeline
@@ -90,7 +90,7 @@ void ForwardStage::destroy() {
CC_SAFE_DELETE(_batchedQueue);
CC_SAFE_DELETE(_instancedQueue);
CC_SAFE_DELETE(_additiveLightQueue);
CC_SAFE_DELETE(_planarShadowQueue);
CC_SAFE_DESTROY_AND_DELETE(_planarShadowQueue);
CC_SAFE_DELETE(_uiPhase);
RenderStage::destroy();
}