From 8321b3e03ed4dcd6be2bb7558ab088ec124ee8ab Mon Sep 17 00:00:00 2001 From: Jialiang Tan Date: Thu, 4 Jan 2024 16:55:47 -0800 Subject: [PATCH] Add error log in ~MemoryManager (#8262) Summary: When leak check flag is false, we shall print the error message. Pull Request resolved: https://github.com/facebookincubator/velox/pull/8262 Reviewed By: xiaoxmeng Differential Revision: D52546224 Pulled By: tanjialiang fbshipit-source-id: d7f15d1e4403bc4849c61b85d7fdfffcfef601dd --- velox/common/memory/Memory.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/velox/common/memory/Memory.cpp b/velox/common/memory/Memory.cpp index 98e91408ee82..573e367a9673 100644 --- a/velox/common/memory/Memory.cpp +++ b/velox/common/memory/Memory.cpp @@ -109,12 +109,18 @@ MemoryManager::MemoryManager(const MemoryManagerOptions& options) } MemoryManager::~MemoryManager() { - if (checkUsageLeak_) { - VELOX_CHECK_EQ( + if (pools_.size() != 0) { + const auto errMsg = fmt::format( + "pools_.size() != 0 ({} vs {}). There are unexpected alive memory " + "pools allocated by user on memory manager destruction:\n{}", pools_.size(), 0, - "There are unexpected alive memory pools allocated by user on memory manager destruction:\n{}", toString(true)); + if (checkUsageLeak_) { + VELOX_FAIL(errMsg); + } else { + LOG(ERROR) << errMsg; + } } }