From: Kosie van der Merwe Date: Tue, 8 Jan 2013 19:24:15 +0000 (-0800) Subject: Fixed memory leak in ShardedLRUCache X-Git-Tag: v1.5.7~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4d339d7462d40c3e01b947445289c3ce2a132046;p=rocksdb.git Fixed memory leak in ShardedLRUCache 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 --- diff --git a/util/cache.cc b/util/cache.cc index 79e5cc9bd..247f3c357 100644 --- a/util/cache.cc +++ b/util/cache.cc @@ -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);