You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/04/30 12:41:39 UTC
[doris] 12/18: [fix](memleak) avoid memleak due to race condition (#19071)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 9e5ec16c3d5df4ec753bf2f20f1d3f84bd6ebb77
Author: Yongqiang YANG <98...@users.noreply.github.com>
AuthorDate: Thu Apr 27 14:22:09 2023 +0800
[fix](memleak) avoid memleak due to race condition (#19071)
---
be/src/util/core_local.cpp | 8 ++++++--
be/src/vec/aggregate_functions/aggregate_function_hll_union_agg.h | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/be/src/util/core_local.cpp b/be/src/util/core_local.cpp
index 2077d87908..4af164573d 100644
--- a/be/src/util/core_local.cpp
+++ b/be/src/util/core_local.cpp
@@ -55,8 +55,12 @@ public:
}
CoreDataBlock* block = _blocks[block_id];
if (block == nullptr) {
- block = new CoreDataBlock();
- _blocks[block_id] = block;
+ std::lock_guard<SpinLock> l(_lock);
+ block = _blocks[block_id];
+ if (block == nullptr) {
+ block = new CoreDataBlock();
+ _blocks[block_id] = block;
+ }
}
size_t offset = (id % ELEMENTS_PER_BLOCK) * ELEMENT_BYTES;
return block->at(offset);
diff --git a/be/src/vec/aggregate_functions/aggregate_function_hll_union_agg.h b/be/src/vec/aggregate_functions/aggregate_function_hll_union_agg.h
index c41e7be7d9..0748088ed9 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_hll_union_agg.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_hll_union_agg.h
@@ -34,6 +34,9 @@ template <bool is_nullable>
struct AggregateFunctionHLLData {
HyperLogLog dst_hll {};
+ AggregateFunctionHLLData() = default;
+ ~AggregateFunctionHLLData() = default;
+
void merge(const AggregateFunctionHLLData& rhs) { dst_hll.merge(rhs.dst_hll); }
void write(BufferWritable& buf) const {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org