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 b152abc292a [fix](faststring) fix memtracking in faststring free (#27731) b152abc292a is described below commit b152abc292a4b025c2a274ed9496b8c0e1c48e15 Author: Kaijie Chen <c...@apache.org> AuthorDate: Wed Nov 29 17:05:14 2023 +0800 [fix](faststring) fix memtracking in faststring free (#27731) --- be/src/util/faststring.cc | 9 +++++---- be/src/util/faststring.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/be/src/util/faststring.cc b/be/src/util/faststring.cc index cf373efec4b..046e08c29d8 100644 --- a/be/src/util/faststring.cc +++ b/be/src/util/faststring.cc @@ -41,14 +41,15 @@ void faststring::GrowArray(size_t newcapacity) { if (len_ > 0) { memcpy(&newdata[0], &data_[0], len_); } - capacity_ = newcapacity; + if (data_ != initial_data_) { - Allocator::free(data_); + Allocator::free(data_, capacity_); } else { ASAN_POISON_MEMORY_REGION(initial_data_, arraysize(initial_data_)); } data_ = newdata.release(); + capacity_ = newcapacity; ASAN_POISON_MEMORY_REGION(data_ + len_, capacity_ - len_); } @@ -57,13 +58,13 @@ void faststring::ShrinkToFitInternal() { if (len_ <= kInitialCapacity) { ASAN_UNPOISON_MEMORY_REGION(initial_data_, len_); memcpy(initial_data_, &data_[0], len_); - Allocator::free(data_); + Allocator::free(data_, capacity_); data_ = initial_data_; capacity_ = kInitialCapacity; } else { std::unique_ptr<uint8_t[]> newdata(reinterpret_cast<uint8_t*>(Allocator::alloc(len_))); memcpy(&newdata[0], &data_[0], len_); - Allocator::free(data_); + Allocator::free(data_, capacity_); data_ = newdata.release(); capacity_ = len_; } diff --git a/be/src/util/faststring.h b/be/src/util/faststring.h index 72a362156df..bd7c07e2d5b 100644 --- a/be/src/util/faststring.h +++ b/be/src/util/faststring.h @@ -54,7 +54,7 @@ public: ~faststring() { ASAN_UNPOISON_MEMORY_REGION(initial_data_, arraysize(initial_data_)); if (data_ != initial_data_) { - Allocator::free(data_); + Allocator::free(data_, capacity_); } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org