diff --git a/src/lazyfree.c b/src/lazyfree.c index 809ebdb57bacf5f8441c9a899200654a399041ad..cfab6a31a0696e106a33051d677786e087b252f3 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);