From 182d5ab798ba2d0aa1003672d1cd798aa6d345ce Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Sun, 26 Jul 2015 20:01:50 +0300 Subject: [PATCH] memtable: fix memory leak Since memtable::partitions is now an intrusive_set, it must be cleared explicitly, or memory is leaked. --- memtable.cc | 4 ++++ memtable.hh | 1 + 2 files changed, 5 insertions(+) diff --git a/memtable.cc b/memtable.cc index 4b331949c5..ca327ce0ec 100644 --- a/memtable.cc +++ b/memtable.cc @@ -10,6 +10,10 @@ memtable::memtable(schema_ptr schema) , partitions(partition_entry::compare(_schema)) { } +memtable::~memtable() { + partitions.clear_and_dispose(std::default_delete()); +} + memtable::const_mutation_partition_ptr memtable::find_partition(const dht::decorated_key& key) const { auto i = partitions.find(key, partition_entry::compare(_schema)); diff --git a/memtable.hh b/memtable.hh index 37c0831297..6c01aac039 100644 --- a/memtable.hh +++ b/memtable.hh @@ -76,6 +76,7 @@ public: using const_mutation_partition_ptr = std::unique_ptr; public: explicit memtable(schema_ptr schema); + ~memtable(); schema_ptr schema() const { return _schema; } mutation_partition& find_or_create_partition(const dht::decorated_key& key); mutation_partition& find_or_create_partition_slow(partition_key_view key);