[CP] [FIX] Fix problem of memory leak in RCTE when encounter large memory allocation

This commit is contained in:
obdev
2024-04-22 09:45:25 +00:00
committed by ob-robot
parent dcf8d2d9b5
commit 327e04ad45
2 changed files with 18 additions and 0 deletions

View File

@ -526,6 +526,7 @@ int ObBreadthFirstSearchBulkOp::reuse()
void ObBreadthFirstSearchBulkOp::destroy()
{
free_input_rows_mem();
free_last_iter_mem();
if (OB_NOT_NULL(mem_context_)) {
DESTROY_CONTEXT(mem_context_);
@ -812,6 +813,22 @@ int ObBreadthFirstSearchBulkOp::init_mem_context()
return ret;
}
//RCTE operator may encounter -4013 memory problem when it want to allocate a very large memory for a new round of iteration data
//at that time, memory is stored in input_rows_, so we have to free them before reset allocator
void ObBreadthFirstSearchBulkOp::free_input_rows_mem()
{
if (OB_ISNULL(malloc_allocator_)) {
// do nothing
} else {
for (int64_t i = 0; i < input_rows_.size(); ++i) {
if (OB_NOT_NULL(input_rows_.at(i))) {
malloc_allocator_->free(input_rows_.at(i));
}
}
input_rows_.reset();
}
}
void ObBreadthFirstSearchBulkOp::free_last_iter_mem()
{
if (OB_ISNULL(malloc_allocator_)) {

View File

@ -333,6 +333,7 @@ public:
int sort_result_output_nodes(int64_t rows_cnt);
int add_row(const ObIArray<ObExpr *> &exprs, ObEvalCtx &eval_ctx);
int init_mem_context();
void free_input_rows_mem();
void free_last_iter_mem();
private: