mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-26 16:30:56 +00:00
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
This commit is contained in:
parent
be8621ffaf
commit
2d41403f45
|
@ -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<TableBuilder> table_builder;
|
||||
table_builder.reset(block_based_tf.NewTableBuilder(
|
||||
tb_options, dest_writer.get()));
|
||||
unique_ptr<Iterator> 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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue