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

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 459f2957041792c1e7961c8a53c53bdfdf3ba880
Author: airborne12 <[email protected]>
AuthorDate: Fri Jul 7 13:00:43 2023 +0800

    [Enhancement](inverted index) reset global instance for 
InvertedIndexSearcherCache when destroy (#21601)
    
    This PR aims to address the need for resetting the 
InvertedIndexSearcherCache during the destroy of doris_be. Given that 
InvertedIndexSearcherCache is a global instance, it is necessary to explicitly 
reset its members.
    
    Implementing this change will effectively eliminate the memory leak 
information that currently appears when doris_be is stopped gracefully. This 
contributes to a cleaner and more efficient shutdown process.
---
 be/src/olap/rowset/segment_v2/inverted_index_cache.h | 12 ++++++++++++
 be/src/runtime/exec_env_init.cpp                     |  1 +
 2 files changed, 13 insertions(+)

diff --git a/be/src/olap/rowset/segment_v2/inverted_index_cache.h 
b/be/src/olap/rowset/segment_v2/inverted_index_cache.h
index 0ab2b18af4..941fb2dc63 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index_cache.h
+++ b/be/src/olap/rowset/segment_v2/inverted_index_cache.h
@@ -77,6 +77,18 @@ public:
     // "capacity" is the capacity of lru cache.
     static void create_global_instance(size_t capacity, uint32_t num_shards = 
16);
 
+    void reset() {
+        _cache.reset();
+        _mem_tracker.reset();
+        // Reset or clear the state of the object.
+    }
+
+    static void reset_global_instance() {
+        if (_s_instance != nullptr) {
+            _s_instance->reset();
+        }
+    }
+
     // Return global instance.
     // Client should call create_global_cache before.
     static InvertedIndexSearcherCache* instance() { return _s_instance; }
diff --git a/be/src/runtime/exec_env_init.cpp b/be/src/runtime/exec_env_init.cpp
index 986bac109e..dbdee56377 100644
--- a/be/src/runtime/exec_env_init.cpp
+++ b/be/src/runtime/exec_env_init.cpp
@@ -407,6 +407,7 @@ void ExecEnv::_destroy() {
     _experimental_mem_tracker.reset();
     _page_no_cache_mem_tracker.reset();
     _brpc_iobuf_block_memory_tracker.reset();
+    InvertedIndexSearcherCache::reset_global_instance();
 
     _is_init = false;
 }


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

Reply via email to