You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2023/04/21 16:34:19 UTC
[doris] branch master updated: [bugfix](memoryleak) inlist is memory leak if the type is int (#18883)
This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 24ee391a7e [bugfix](memoryleak) inlist is memory leak if the type is int (#18883)
24ee391a7e is described below
commit 24ee391a7eeb7dee0b86c1f0ae1b6ed47331935d
Author: yiguolei <67...@qq.com>
AuthorDate: Sat Apr 22 00:34:10 2023 +0800
[bugfix](memoryleak) inlist is memory leak if the type is int (#18883)
* [bugfix](memoryleak) inlist is memory leak if the type is int
---------
Co-authored-by: yiguolei <yi...@gmail.com>
Co-authored-by: github-actions[bot] <41...@users.noreply.github.com>
---
be/src/olap/in_list_predicate.h | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/be/src/olap/in_list_predicate.h b/be/src/olap/in_list_predicate.h
index abecd69077..7243e11210 100644
--- a/be/src/olap/in_list_predicate.h
+++ b/be/src/olap/in_list_predicate.h
@@ -89,9 +89,9 @@ public:
const ConvertFunc& convert, bool is_opposite = false,
const TabletColumn* col = nullptr, vectorized::Arena* arena = nullptr)
: ColumnPredicate(column_id, is_opposite),
- _values(new HybridSetType()),
_min_value(type_limit<T>::max()),
_max_value(type_limit<T>::min()) {
+ _values = std::make_shared<HybridSetType>();
for (const auto& condition : conditions) {
T tmp;
if constexpr (Type == TYPE_STRING || Type == TYPE_CHAR) {
@@ -115,8 +115,7 @@ public:
CHECK(hybrid_set != nullptr);
if constexpr (is_string_type(Type) || Type == TYPE_DECIMALV2 || is_date_type(Type)) {
- _values = new HybridSetType();
-
+ _values = std::make_shared<HybridSetType>();
if constexpr (is_string_type(Type)) {
HybridSetBase::IteratorBase* iter = hybrid_set->begin();
while (iter->has_next()) {
@@ -168,7 +167,8 @@ public:
CHECK(Type == TYPE_DATETIMEV2 || Type == TYPE_DATEV2);
}
} else {
- _values = reinterpret_cast<HybridSetType*>(hybrid_set.get());
+ // shared from the caller, so it needs to be shared ptr
+ _values = hybrid_set;
}
HybridSetBase::IteratorBase* iter = _values->begin();
while (iter->has_next()) {
@@ -178,11 +178,7 @@ public:
}
}
- ~InListPredicateBase() override {
- if constexpr (is_string_type(Type) || Type == TYPE_DECIMALV2 || is_date_type(Type)) {
- delete _values;
- }
- }
+ ~InListPredicateBase() override = default;
PredicateType type() const override { return PT; }
@@ -423,7 +419,7 @@ private:
DCHECK((segid.first.hi | segid.first.mi | segid.first.lo) != 0);
auto& value_in_dict_flags = _segment_id_to_value_in_dict_flags[segid];
if (value_in_dict_flags.empty()) {
- nested_col_ptr->find_codes(_values, value_in_dict_flags);
+ nested_col_ptr->find_codes(_values.get(), value_in_dict_flags);
}
CHECK(value_in_dict_flags.size() == nested_col_ptr->dict_size())
@@ -488,7 +484,7 @@ private:
auto& value_in_dict_flags =
_segment_id_to_value_in_dict_flags[column->get_rowset_segment_id()];
if (value_in_dict_flags.empty()) {
- nested_col_ptr->find_codes(_values, value_in_dict_flags);
+ nested_col_ptr->find_codes(_values.get(), value_in_dict_flags);
}
for (uint16_t i = 0; i < size; i++) {
@@ -570,7 +566,7 @@ private:
}
}
- HybridSetType* _values;
+ std::shared_ptr<HybridSetBase> _values;
mutable std::map<std::pair<RowsetId, uint32_t>, std::vector<vectorized::UInt8>>
_segment_id_to_value_in_dict_flags;
T _min_value;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org