Resolve memory leak when discard Graphics::CommandBuffer 32/317632/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Thu, 12 Sep 2024 11:06:57 +0000 (20:06 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Thu, 12 Sep 2024 12:08:09 +0000 (21:08 +0900)
Change-Id: I17c23505bfc79b2239e316420ffbd48fda0892f9
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-egl-application.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-vk-application.cpp
dali/internal/graphics/gles-impl/gles-graphics-command-buffer.cpp

index 6e6b3fc7fa11e79c5c246af687f5dd805dfcd516..1fa33c453d6564af570d39350fef3527efa13d16 100644 (file)
@@ -101,6 +101,10 @@ void TestApplication::InitializeCore()
 
 TestApplication::~TestApplication()
 {
+  if(DALI_LIKELY(mCore))
+  {
+    mCore->ContextDestroyed();
+  }
   Dali::Integration::Log::UninstallLogFunction();
   delete mCore;
 }
index 3b61d00681ec2c0021c393087a06c522b7db9d6c..1f17af3133589db22f8ec6aa7ccf8741a1f5c411 100644 (file)
@@ -102,6 +102,10 @@ void TestGraphicsApplication::InitializeCore()
 
 TestGraphicsApplication::~TestGraphicsApplication()
 {
+  if(DALI_LIKELY(mCore))
+  {
+    mCore->ContextDestroyed();
+  }
   mGraphicsController.Shutdown();
   Dali::Integration::Log::UninstallLogFunction();
   delete mCore;
index 224986bdf149668f35c3708d1b92fc4aed865a3a..10ae54c0368db55bbfdae91997d3bff1660557c3 100644 (file)
@@ -111,6 +111,10 @@ void TestGraphicsApplication::InitializeCore()
 
 TestGraphicsApplication::~TestGraphicsApplication()
 {
+  if(DALI_LIKELY(mCore))
+  {
+    mCore->ContextDestroyed();
+  }
   mGraphics.GetController().Shutdown();
   Dali::Integration::Log::UninstallLogFunction();
   delete mCore;
index e6a75c47cc9b4d09d61334d6fecd284cf2345647..776711fc7156ab32b52ce3d8a36dcc882fe1a8e2 100644 (file)
@@ -58,6 +58,7 @@ class CommandPool
     inline void clear()
     {
       free(ptr);
+      ptr      = nullptr;
       capacity = 0;
       dataSize = 0;
     }
@@ -579,7 +580,11 @@ void CommandBuffer::PresentRenderTarget(GLES::RenderTarget* renderTarget)
 
 void CommandBuffer::DestroyResource()
 {
-  // Nothing to do
+  if(DALI_LIKELY(mCommandPool))
+  {
+    mCommandPool->Rollback(true); // Discard memory here!
+  }
+  mCommandPool.reset();
 }
 
 bool CommandBuffer::InitializeResource()