[Performance Branch] Fix memory leak in HashLinkListRep.GetIterator()

Summary: Full list constructed for full iterator can be leaked. This was a bug introduced when I copy the full iterator codes from hash skip list to hash link list. This patch fixes it.

Test Plan: Run valgrind test against db_test and make sure the memory leak is fixed

Reviewers: kailiu, haobo

Reviewed By: kailiu

CC: igor, leveldb

Differential Revision: https://reviews.facebook.net/D15093
This commit is contained in:
Siying Dong 2014-01-09 22:25:03 -08:00
parent 237a3da677
commit 5b5ab0c1a8
2 changed files with 6 additions and 3 deletions

View File

@ -108,7 +108,6 @@ class PrefixTest {
options.min_write_buffer_number_to_merge =
FLAGS_min_write_buffer_number_to_merge;
options.comparator = new TestKeyComparator();
options.memtable_prefix_bloom_bits = FLAGS_memtable_prefix_bloom_bits;
options.memtable_prefix_bloom_probes = FLAGS_memtable_prefix_bloom_probes;
@ -142,7 +141,9 @@ class PrefixTest {
return false;
}
PrefixTest() : option_config_(kBegin) { }
PrefixTest() : option_config_(kBegin) {
options.comparator = new TestKeyComparator();
}
~PrefixTest() {
delete options.comparator;
}

View File

@ -125,7 +125,7 @@ class HashLinkListRep : public MemTableRep {
class FullListIterator : public MemTableRep::Iterator {
public:
explicit FullListIterator(FullList* list)
: iter_(list) {}
: iter_(list), full_list_(list) {}
virtual ~FullListIterator() {
}
@ -177,6 +177,8 @@ class HashLinkListRep : public MemTableRep {
}
private:
FullList::Iterator iter_;
// To destruct with the iterator.
std::unique_ptr<FullList> full_list_;
std::string tmp_; // For passing to EncodeKey
};