Skip to content

Commit

Permalink
Merge pull request #26 from imay/master
Browse files Browse the repository at this point in the history
fix memory release leak when load job's broker_scan_node fail
  • Loading branch information
chaoyli authored Aug 17, 2017
2 parents 1a6cad4 + adac2b4 commit bbef0d9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion be/src/runtime/data_spliter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,13 @@ Status DataSpliter::close(RuntimeState* state, Status close_status) {
is_ok = false;
err_status = status;
}
iter.second->reset();
iter.second->clear();
}
}
} else {
for (const auto& iter : _batch_map) {
iter.second->clear();
}
}
// finish sink
for (const auto& iter : _dpp_sink_vec) {
Expand Down
11 changes: 10 additions & 1 deletion be/src/runtime/row_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ RowBatch::RowBatch(const RowDescriptor& row_desc, const TRowBatch& input_batch,
}
}

RowBatch::~RowBatch() {
void RowBatch::clear() {
if (_cleared) {
return;
}

_tuple_data_pool->free_all();
for (int i = 0; i < _io_buffers.size(); ++i) {
_io_buffers[i]->return_buffer();
Expand All @@ -181,6 +185,11 @@ RowBatch::~RowBatch() {
_mem_tracker->release(_tuple_ptrs_size);
_tuple_ptrs = NULL;
}
_cleared = true;
}

RowBatch::~RowBatch() {
clear();
}

int RowBatch::serialize(TRowBatch* output_batch) {
Expand Down
4 changes: 4 additions & 0 deletions be/src/runtime/row_batch.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class RowBatch : public RowBatchInterface {
// - buffer handles from the io mgr
virtual ~RowBatch();

// used to c
void clear();

static const int INVALID_ROW_INDEX = -1;

// Add n rows of tuple pointers after the last committed row and return its index.
Expand Down Expand Up @@ -486,6 +489,7 @@ class RowBatch : public RowBatchInterface {
std::string _compression_scratch;

int _scanner_id;
bool _cleared = false;
};

/// Macros for iterating through '_row_batch', starting at '_start_row_idx'.
Expand Down

0 comments on commit bbef0d9

Please sign in to comment.