• Ozan Tezcan's avatar
    Fix memory leak of jemalloc tcache on function flush command (#13661) · 9ebf80a2
    Ozan Tezcan authored
    Starting from https://github.com/redis/redis/pull/13133
    
    , we allocate a
    jemalloc thread cache and use it for lua vm.
    On certain cases, like `script flush` or `function flush` command, we
    free the existing thread cache and create a new one.
    
    Though, for `function flush`, we were not actually destroying the
    existing thread cache itself. Each call creates a new thread cache on
    jemalloc and we leak the previous thread cache instances. Jemalloc
    allows maximum 4096 thread cache instances. If we reach this limit,
    Redis prints "Failed creating the lua jemalloc tcache" log and abort.
    
    There are other cases that can cause this memory leak, including
    replication scenarios when emptyData() is called.
    
    The implication is that it looks like redis `used_memory` is low, but
    `allocator_allocated` and RSS remain high.
    Co-authored-by: default avatardebing.sun <debing.sun@redis.com>
    9ebf80a2
eval.c 62.6 KB