summaryrefslogtreecommitdiff
path: root/src/lazyfree.c
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2018-01-15 12:43:55 +0100
committerGitHub <noreply@github.com>2018-01-15 12:43:55 +0100
commit1ed5ac7ce5322b3c57c1637574b9e87e1af7b76d (patch)
tree3233a3e37b4324cf6c45b39128397420edc10402 /src/lazyfree.c
parentaeeb7477960ed0f398027e2c6ca7d9e8af9d8a58 (diff)
parent0517ab8397d6077660f46d9f9d320b3106c13a06 (diff)
downloadredis-1ed5ac7ce5322b3c57c1637574b9e87e1af7b76d.tar.gz
Merge pull request #4601 from soloestoy/fix-memoryleak-for-lazy-server-del
lazyfree: fix memory leak for lazyfree-lazy-server-del
Diffstat (limited to 'src/lazyfree.c')
-rw-r--r--src/lazyfree.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lazyfree.c b/src/lazyfree.c
index 809ebdb57..cfab6a31a 100644
--- a/src/lazyfree.c
+++ b/src/lazyfree.c
@@ -64,9 +64,10 @@ int dbAsyncDelete(redisDb *db, robj *key) {
robj *val = dictGetVal(de);
size_t free_effort = lazyfreeGetFreeEffort(val);
- /* If releasing the object is too much work, let's put it into the
- * lazy free list. */
- if (free_effort > LAZYFREE_THRESHOLD) {
+ /* If releasing the object is too much work and the refcount
+ * is 1, that means the object really needs to be freed,
+ * let's put it into the lazy free list. */
+ if (free_effort > LAZYFREE_THRESHOLD && val->refcount == 1) {
atomicIncr(lazyfree_objects,1);
bioCreateBackgroundJob(BIO_LAZY_FREE,val,NULL,NULL);
dictSetVal(db->dict,de,NULL);