From 2d41403f457ed21873ef14657aecc30e94c50d4a Mon Sep 17 00:00:00 2001 From: Boyang Zhang Date: Tue, 4 Aug 2015 08:42:34 -0700 Subject: [PATCH] Made change to fix the memory leak Summary: So I took a look and I used a pointer to TableBuilder. Changed it to a unique_ptr. I think this should work, but I cannot run valgrind correctly on my local machine to test it. Test Plan: Run valgrind, but it's not working locally. It says I'm executing an unrecognized instruction. Reviewers: yhchiang Subscribers: dhruba, sdong Differential Revision: https://reviews.facebook.net/D43485 --- util/sst_dump_tool.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/util/sst_dump_tool.cc b/util/sst_dump_tool.cc index 0f135d8418..a1d18e4c52 100644 --- a/util/sst_dump_tool.cc +++ b/util/sst_dump_tool.cc @@ -121,22 +121,23 @@ uint64_t SstFileReader::CalculateCompressedTableSize( BlockBasedTableOptions table_options; table_options.block_size = block_size; BlockBasedTableFactory block_based_tf(table_options); - TableBuilder* table_builder_ = - block_based_tf.NewTableBuilder(tb_options, dest_writer.get()); + unique_ptr table_builder; + table_builder.reset(block_based_tf.NewTableBuilder( + tb_options, dest_writer.get())); unique_ptr iter(table_reader_->NewIterator(ReadOptions())); for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { if (!iter->status().ok()) { fputs(iter->status().ToString().c_str(), stderr); exit(1); } - table_builder_->Add(iter->key(), iter->value()); + table_builder->Add(iter->key(), iter->value()); } - Status s = table_builder_->Finish(); + Status s = table_builder->Finish(); if (!s.ok()) { fputs(s.ToString().c_str(), stderr); exit(1); } - uint64_t size = table_builder_->FileSize(); + uint64_t size = table_builder->FileSize(); env->DeleteFile(testFileName); return size; }