Redis memory usage results are not as expected

Viewed 164

I am using

Redis version=6.0.5, bits=64

Here is the order of command execution:

hset zq eee  rr1
info memory -> used_memory:1064704
hset zq eep  rr2
info memory ->used_memory:1064704 
hset zq eei  rr3
info memory ->used_memory:1064720 
hset zq eeu  rr4
info memory ->used_memory:1064736   
hset zq eeu  rr5
info memory ->used_memory:1064736   

My expectation is to allocate 16 memory and use 10,But not like this 10 here refers to 2 * (prev_len(1)+encoding&len(1)+content(3))

1 Answers

INFO MEMORY is taking into account none relevant memory allocation. You should use MEMORY USAGE.

e.g.

127.0.0.1:6379> hset zq eee  rr1
(integer) 1
127.0.0.1:6379> MEMORY USAGE zq
(integer) 65
127.0.0.1:6379> hset zq eep  rr2
(integer) 1
127.0.0.1:6379> MEMORY USAGE zq
(integer) 75
127.0.0.1:6379> hset zq eei  rr3
(integer) 1
127.0.0.1:6379> MEMORY USAGE zq
(integer) 85
127.0.0.1:6379> hset zq eeu  rr4
(integer) 1
Related