[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
main
Siying Dong 11 years ago
parent 237a3da677
commit 5b5ab0c1a8
  1. 5
      db/prefix_test.cc
  2. 4
      util/hash_linklist_rep.cc

@ -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;
}

@ -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
};

Loading…
Cancel
Save