From cc09840d513d457a1ff4277d2adf64ee56667036 Mon Sep 17 00:00:00 2001 From: nroskill Date: Tue, 30 Apr 2024 08:45:15 +0000 Subject: [PATCH] [CP] add diagnose for LfFIFO --- .../src/lib/allocator/ob_lf_fifo_allocator.h | 1 - .../oblib/src/lib/allocator/ob_vslice_alloc.h | 22 +++++-------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/deps/oblib/src/lib/allocator/ob_lf_fifo_allocator.h b/deps/oblib/src/lib/allocator/ob_lf_fifo_allocator.h index 6885f9fa4..febeded0c 100644 --- a/deps/oblib/src/lib/allocator/ob_lf_fifo_allocator.h +++ b/deps/oblib/src/lib/allocator/ob_lf_fifo_allocator.h @@ -53,7 +53,6 @@ public: mattr_.tenant_id_ = tenant_id; return init(page_size, mattr_, cache_page_count, total_limit); } - void destroy() { ObVSliceAlloc::purge_extra_cached_block(0); } public: void *alloc(const int64_t size) { return ObVSliceAlloc::alloc(size); } void *alloc(const int64_t size, const ObMemAttr &attr) { UNUSED(attr); return alloc(size); } diff --git a/deps/oblib/src/lib/allocator/ob_vslice_alloc.h b/deps/oblib/src/lib/allocator/ob_vslice_alloc.h index b895148a8..3c232f855 100644 --- a/deps/oblib/src/lib/allocator/ob_vslice_alloc.h +++ b/deps/oblib/src/lib/allocator/ob_vslice_alloc.h @@ -100,22 +100,7 @@ public: return ret; } void destroy() { - for(int i = MAX_ARENA_NUM - 1; i >= 0; i--) { - Arena& arena = arena_[i]; - Block* old_blk = arena.clear(); - if (NULL != old_blk) { - int64_t old_pos = INT64_MAX; - if (old_blk->freeze(old_pos)) { - arena.sync(); - if (old_blk->retire(old_pos)) { - destroy_block(old_blk); - } else { - // can not monitor all leak !!! - LIB_LOG_RET(ERROR, common::OB_ERR_UNEXPECTED, "there was memory leak", K(old_blk->ref_)); - } - } - } - } + purge_extra_cached_block(0, true); bsize_ = 0; } void set_nway(int nway) { @@ -225,7 +210,7 @@ public: #endif } - void purge_extra_cached_block(int keep) { + void purge_extra_cached_block(int keep, bool need_check = false) { for(int i = MAX_ARENA_NUM - 1; i >= keep; i--) { Arena& arena = arena_[i]; arena.ref(1); @@ -237,6 +222,9 @@ public: arena.sync(); if (old_blk->retire(old_pos)) { destroy_block(old_blk); + } else if (need_check) { + // can not monitor all leak !!! + LIB_LOG_RET(ERROR, common::OB_ERR_UNEXPECTED, "there was memory leak", K(old_blk->ref_)); } } else { arena.ref(-1);