diff options
author | zhaozhao.zz <zhaozhao.zz@alibaba-inc.com> | 2018-01-15 00:45:37 +0800 |
---|---|---|
committer | zhaozhao.zz <zhaozhao.zz@alibaba-inc.com> | 2018-01-15 00:45:37 +0800 |
commit | 0517ab8397d6077660f46d9f9d320b3106c13a06 (patch) | |
tree | 7d8532c64271060c44719c62d5338942c308053b /src/lazyfree.c | |
parent | 238c9bd0863e713f018587e79f452ade845bee91 (diff) | |
download | redis-0517ab8397d6077660f46d9f9d320b3106c13a06.tar.gz |
lazyfree: fix memory leak for lazyfree-lazy-server-del
Diffstat (limited to 'src/lazyfree.c')
-rw-r--r-- | src/lazyfree.c | 7 |
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); |