From dd96b22f55466ba839a7f04480b68ea894b7a2b7 Mon Sep 17 00:00:00 2001 From: wangt1xiuyi <13547954130@163.com> Date: Wed, 16 Nov 2022 14:05:38 +0000 Subject: [PATCH] fix get histogram memory leak and some failed cases --- deps/oblib/src/lib/stat/ob_di_tls.h | 12 ++++++------ src/share/stat/ob_opt_column_stat.h | 4 ++-- src/share/stat/ob_opt_stat_service.cpp | 5 ++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/deps/oblib/src/lib/stat/ob_di_tls.h b/deps/oblib/src/lib/stat/ob_di_tls.h index 4e8702ef07..17b22557f8 100644 --- a/deps/oblib/src/lib/stat/ob_di_tls.h +++ b/deps/oblib/src/lib/stat/ob_di_tls.h @@ -18,10 +18,10 @@ namespace oceanbase { -namespace common -{ - -template +namespace common +{ + +template class ObDITls { public: @@ -66,5 +66,5 @@ T* ObDITls::get_instance() } } -} -#endif +} +#endif diff --git a/src/share/stat/ob_opt_column_stat.h b/src/share/stat/ob_opt_column_stat.h index db7f8d49c0..195b0fd746 100644 --- a/src/share/stat/ob_opt_column_stat.h +++ b/src/share/stat/ob_opt_column_stat.h @@ -89,7 +89,7 @@ public: pop_count_(0) {} - ~ObHistogram() {} + ~ObHistogram() { reset(); } void reset(); @@ -219,7 +219,7 @@ public: explicit ObOptColumnStat(common::ObIAllocator &allocator); - ~ObOptColumnStat() {} + ~ObOptColumnStat() { histogram_.reset(); } uint64_t get_table_id() const { return table_id_; } void set_table_id(uint64_t tid) { table_id_ = tid; } diff --git a/src/share/stat/ob_opt_stat_service.cpp b/src/share/stat/ob_opt_stat_service.cpp index e756b8935e..d8e935aefc 100644 --- a/src/share/stat/ob_opt_stat_service.cpp +++ b/src/share/stat/ob_opt_stat_service.cpp @@ -237,7 +237,10 @@ int ObOptStatService::load_column_stat_and_put_cache(const uint64_t tenant_id, LOG_WARN("puts column stat into cache failed.", K(ret)); } else if (OB_FAIL(handles.push_back(handle))) { LOG_WARN("failed to push back", K(ret)); - } else {/*do nothing*/} + } else { + key_column_stats.at(i).stat_->~ObOptColumnStat(); + key_column_stats.at(i).stat_ = NULL; + } } } return ret;