diff --git a/be/src/olap/rowset/segment_v2/bitshuffle_page.h b/be/src/olap/rowset/segment_v2/bitshuffle_page.h index 02ab39f3a3..cd54b6bdae 100644 --- a/be/src/olap/rowset/segment_v2/bitshuffle_page.h +++ b/be/src/olap/rowset/segment_v2/bitshuffle_page.h @@ -216,9 +216,7 @@ public: _cur_index(0) {} ~BitShufflePageDecoder() { - if (_chunk.size != 0) { - ChunkAllocator::instance()->free(_chunk); - } + ChunkAllocator::instance()->free(_chunk); } Status init() override { diff --git a/be/src/runtime/memory/chunk.h b/be/src/runtime/memory/chunk.h index 47d5372ba2..332631d3fb 100644 --- a/be/src/runtime/memory/chunk.h +++ b/be/src/runtime/memory/chunk.h @@ -27,9 +27,9 @@ namespace doris { // will result in recompilation of all files. So, we put it in a // file to keep this file simple and infrequently changed. struct Chunk { - uint8_t* data; - size_t size; - int core_id; + uint8_t* data = nullptr; + size_t size = 0; + int core_id = -1; }; } // namespace doris diff --git a/be/src/runtime/memory/chunk_allocator.cpp b/be/src/runtime/memory/chunk_allocator.cpp index 82327f273a..cbc2462953 100644 --- a/be/src/runtime/memory/chunk_allocator.cpp +++ b/be/src/runtime/memory/chunk_allocator.cpp @@ -170,6 +170,9 @@ bool ChunkAllocator::allocate(size_t size, Chunk* chunk) { } void ChunkAllocator::free(const Chunk& chunk) { + if (chunk.core_id == -1) { + return; + } int64_t old_reserved_bytes = _reserved_bytes; int64_t new_reserved_bytes = 0; do { @@ -190,7 +193,6 @@ void ChunkAllocator::free(const Chunk& chunk) { _arenas[chunk.core_id]->push_free_chunk(chunk.data, chunk.size); } - bool ChunkAllocator::allocate_align(size_t size, Chunk* chunk) { return allocate(BitUtil::RoundUpToPowerOfTwo(size), chunk); }