From f9b0da44444b5434c4410db6eb72959fe101d12f Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 24 Mar 2023 07:11:52 +0000 Subject: [PATCH] to issue<48587285>:fix memory leak about pl collection shrink --- src/pl/ob_pl_allocator.cpp | 10 ++++++++++ src/pl/ob_pl_allocator.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/pl/ob_pl_allocator.cpp b/src/pl/ob_pl_allocator.cpp index b3807dde6..6a16155cd 100644 --- a/src/pl/ob_pl_allocator.cpp +++ b/src/pl/ob_pl_allocator.cpp @@ -74,6 +74,16 @@ int ObPLAllocator::shrink() return ret; } +int ObPLCollAllocator::free_child_coll(ObPLCollection &dest) +{ + int ret = OB_SUCCESS; + + for (int64_t i = 0; OB_SUCC(ret) && i < dest.get_count(); ++i) { + OZ (ObUserDefinedType::destruct_obj(dest.get_data()[i], NULL)); + } + return ret; +} + int ObPLCollAllocator::copy_all_element_with_new_allocator(ObIAllocator *allocator) { int ret = OB_SUCCESS; diff --git a/src/pl/ob_pl_allocator.h b/src/pl/ob_pl_allocator.h index 6b06ab5e0..9221daa84 100644 --- a/src/pl/ob_pl_allocator.h +++ b/src/pl/ob_pl_allocator.h @@ -81,6 +81,7 @@ public: ObPLAllocator(), coll_(coll) {} virtual int copy_all_element_with_new_allocator(ObIAllocator *allocator) override; + static int free_child_coll(ObPLCollection &dest); private: ObPLCollection* coll_;