]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Fixed memory leak in ShardedLRUCache
authorKosie van der Merwe <kosie.vandermerwe@gmail.com>
Tue, 8 Jan 2013 19:24:15 +0000 (11:24 -0800)
committerKosie van der Merwe <kosie.vandermerwe@gmail.com>
Tue, 8 Jan 2013 19:24:15 +0000 (11:24 -0800)
Summary: `~ShardedLRUCache()` was empty despite `init()` allocating memory on the heap. Fixed the leak by freeing memory allocated by `init()`.

Test Plan:
make check

Ran valgrind on db_test before and after patch and saw leaked memory went down

Reviewers: vamsi, dhruba, emayanke, sheki

Reviewed By: dhruba

CC: leveldb
Differential Revision: https://reviews.facebook.net/D7791

util/cache.cc

index 79e5cc9bd0b0e68bd204696794b1d48989b875a2..247f3c35729ac9df86252b4a9332bf71129ff0eb 100644 (file)
@@ -304,7 +304,9 @@ class ShardedLRUCache : public Cache {
      : last_id_(0) {
     init(capacity, numShardBits);
   }
-  virtual ~ShardedLRUCache() { }
+  virtual ~ShardedLRUCache() {
+    delete[] shard_;
+  }
   virtual Handle* Insert(const Slice& key, void* value, size_t charge,
                          void (*deleter)(const Slice& key, void* value)) {
     const uint32_t hash = HashSlice(key);