• Chen Tianjie's avatar
    Optimize dictTypeResizeAllowed to avoid mistaken OOM judgement. (#12950) · f81c3fd8
    Chen Tianjie authored
    When doing dict resizing, dictTypeResizeAllowed is used to judge whether
    the new allocated memory for rehashing would cause OOM.
    
    However when shrinking, we alloc `_dictNextExp(d->ht_used[0])` bytes of
    memory, while in `dictTypeResizeAllowed` we still use
    `_dictNextExp(d->ht_used[0]+1)` as the new allocated memory size. This
    will overestimate the memory used by shrinking at special conditions,
    causing a false OOM judgement.
    f81c3fd8
dict.c 68.8 KB