This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new ffc69befc88 branch-4.1: [improvement](storage) Release unused memory 
earlier, rather than leaving it to the memory pool for guaranteed release 
#57215 (#67956)
ffc69befc88 is described below

commit ffc69befc88e123d91fe6a687f341af04705fb0f
Author: Refrain <[email protected]>
AuthorDate: Tue Sep 15 18:41:55 2026 +0800

    branch-4.1: [improvement](storage) Release unused memory earlier, rather 
than leaving it to the memory pool for guaranteed release #57215 (#67956)
    
    Cherry-picked from #57215.
    
    ### What problem does this PR solve?
    
    Problem Summary: During aggregation, `cur_row` is no longer needed after
    merging, but its aggregation state remained allocated until memory-pool
    teardown. Clear the merged row's aggregation state immediately.
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test: Directly compiled `be/src/load/memtable/memtable.cpp` and linked
    `src/load/libLoad.a`. Full BE UT build is blocked by a pre-existing
    Lance API/header mismatch in `be/src/format_v2/table/lance_reader.cpp`.
    - Behavior changed: No
    - Does this need documentation: No
---
 be/src/load/memtable/memtable.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/be/src/load/memtable/memtable.cpp 
b/be/src/load/memtable/memtable.cpp
index a36e0d588d6..741775eae2e 100644
--- a/be/src/load/memtable/memtable.cpp
+++ b/be/src/load/memtable/memtable.cpp
@@ -483,7 +483,7 @@ void MemTable::_clear_row_agg(RowInBlock* row) {
         row->remove_init_agg();
     }
 }
-
+// only in `to_block` the `is_final` flag will be true, in other cases, it 
will be false
 template <bool is_final, bool has_skip_bitmap_col>
 void MemTable::_aggregate() {
     SCOPED_RAW_TIMER(&_stat.agg_ns);
@@ -507,6 +507,8 @@ void MemTable::_aggregate() {
                 }
                 _stat.merged_rows++;
                 
_aggregate_two_row_in_block<has_skip_bitmap_col>(mutable_block, cur_row, 
prev_row);
+                // Clean up aggregation state of the merged row to avoid 
memory leak
+                _clear_row_agg(cur_row);
             } else {
                 prev_row = cur_row;
                 if (!temp_row_in_blocks.empty()) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to