[Bug] fix memory leakage problem in inference mode
authorSeungbaek Hong <sb92.hong@samsung.com>
Mon, 10 Feb 2025 10:26:23 +0000 (19:26 +0900)
committerjijoong.moon <jijoong.moon@samsung.com>
Tue, 11 Feb 2025 05:45:51 +0000 (14:45 +0900)
this patch fix a memory leakage issue in inference mode.

The problem occurred because even though deallocation was performed,
vectors inside the memory pool were still remained.

**Self evaluation:**

Build test: [x]Passed [ ]Failed [ ]Skipped
Run test: [x]Passed [ ]Failed [ ]Skipped

Signed-off-by: Seungbaek Hong <sb92.hong@samsung.com>
nntrainer/tensor/memory_pool.cpp

index 782dce1fb8a3d5dbf4cee4c09025ebaeb493f483..fc96dd8d935a4517026ecc507e72eefe11bf1b65 100644 (file)
@@ -130,6 +130,10 @@ std::shared_ptr<MemoryData> MemoryPool::getMemory(unsigned int idx) {
 void MemoryPool::deallocate() {
   if (mem_pool != nullptr) {
     free(mem_pool);
+    memory_size.clear();
+    memory_validity.clear();
+    memory_exec_order.clear();
+    memory_is_wgrad.clear();
     PROFILE_MEM_DEALLOC(mem_pool);
   }