From 61f211e5693a1f0aeccdc5db4b814a8946339488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E6=80=9D=E8=BF=9C?= Date: Thu, 21 Nov 2024 21:19:20 +0800 Subject: [PATCH] fix memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周思远 --- .../render_service_base/src/render/rs_image_base.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/render/rs_image_base.cpp b/rosen/modules/render_service_base/src/render/rs_image_base.cpp index e96856a46c..ac88d9b412 100644 --- a/rosen/modules/render_service_base/src/render/rs_image_base.cpp +++ b/rosen/modules/render_service_base/src/render/rs_image_base.cpp @@ -49,7 +49,11 @@ RSImageBase::~RSImageBase() #endif pixelMap_ = nullptr; if (uniqueId_ > 0) { - RSImageCache::Instance().CollectUniqueId(uniqueId_); + if (renderServiceImage_ || isDrawn_) { + RSImageCache::Instance().CollectUniqueId(uniqueId_); + } else { + RSImageCache::Instance().ReleasePixelMapCache(uniqueId_); + } } #if defined(ROSEN_OHOS) && defined(RS_ENABLE_VK) if (RSSystemProperties::GetGpuApiType() == GpuApiType::VULKAN ||