xinyiZzz commented on code in PR #19472:
URL: https://github.com/apache/doris/pull/19472#discussion_r1193188764
##########
be/src/olap/rowset/segment_v2/page_handle.h:
##########
@@ -46,42 +46,49 @@ class PageHandle {
: _is_data_owner(false), _cache_data(std::move(cache_data)) {}
// Move constructor
- PageHandle(PageHandle&& other) noexcept
- : _is_data_owner(false),
- _data(std::move(other._data)),
- _cache_data(std::move(other._cache_data)) {
+ PageHandle(PageHandle&& other) noexcept :
_cache_data(std::move(other._cache_data)) {
// we can use std::exchange if we switch c++14 on
std::swap(_is_data_owner, other._is_data_owner);
+ _data.swap(other._data);
}
PageHandle& operator=(PageHandle&& other) noexcept {
std::swap(_is_data_owner, other._is_data_owner);
- _data = std::move(other._data);
+ _data.swap(other._data);
_cache_data = std::move(other._cache_data);
return *this;
}
~PageHandle() {
if (_is_data_owner && _data.size > 0) {
- delete[] _data.data;
ExecEnv::GetInstance()->page_no_cache_mem_tracker()->consume(-_data.size);
Review Comment:
Because DataPage will automatically call `free` when it is destructed
The memory life cycle is the same as DataPage, and does not rely on manual
release, which seems to be more exception-safe
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]