This is an automated email from the ASF dual-hosted git repository.

philo pushed a commit to branch branch-1.4
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/branch-1.4 by this push:
     new 583733417c [Branch-1.4][GLUTEN-9383][VL] Backport: fix leak when 
growing capacity (#9663)
583733417c is described below

commit 583733417c5721ef80611c73509fc9a4842d37c4
Author: Zhen Wang <[email protected]>
AuthorDate: Fri May 16 21:54:45 2025 +0800

    [Branch-1.4][GLUTEN-9383][VL] Backport: fix leak when growing capacity 
(#9663)
---
 cpp/velox/memory/VeloxMemoryManager.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/cpp/velox/memory/VeloxMemoryManager.cc 
b/cpp/velox/memory/VeloxMemoryManager.cc
index 3aeb50e451..4a41be5288 100644
--- a/cpp/velox/memory/VeloxMemoryManager.cc
+++ b/cpp/velox/memory/VeloxMemoryManager.cc
@@ -168,7 +168,13 @@ class ListenableArbitrator : public 
velox::memory::MemoryArbitrator {
     }
     auto reclaimedFreeBytes = shrinkPool(pool, 0);
     auto neededBytes = velox::bits::roundUp(bytes - reclaimedFreeBytes, 
memoryPoolTransferCapacity_);
-    listener_->allocationChanged(neededBytes);
+    try {
+      listener_->allocationChanged(neededBytes);
+    } catch (const std::exception&) {
+      // if allocationChanged failed, we need to free the reclaimed bytes
+      listener_->allocationChanged(-reclaimedFreeBytes);
+      std::rethrow_exception(std::current_exception());
+    }
     auto ret = growPool(pool, reclaimedFreeBytes + neededBytes, bytes);
     VELOX_CHECK(
         ret,


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to