Reputation: 115
I am running a local redis server. Had one bad key in redis which was occupying lot of memory. Before deleting that key "info memory" was showing 5.3GB as occupied memory. That bad key occupied around 800MB of data. This is based on "debug object " output.
After deleting that key, the memory almost double that size got freed. The expectation was around 800MB only.
Any ideas as to what is behind this ? Running on ubuntu.
127.0.0.1:6379[3]> info
# Server
redis_version:2.8.9
127.0.0.1:6379[3]> info memory
# Memory
used_memory:5746884728
used_memory_human:5.35G
used_memory_rss:6382206976
used_memory_peak:8865352096
used_memory_peak_human:8.26G
used_memory_lua:37888
mem_fragmentation_ratio:1.11
mem_allocator:jemalloc-3.2.0
127.0.0.1:6379[3]> debug object c43d3e42-7e63-47f3-bb63-b58a897c29a6
Value at:0x7f77a1db1d10 refcount:1 encoding:linkedlist
serializedlength:814237852 lru:994050 lru_seconds_idle:99559
(5.53s)
127.0.0.1:6379[3]> del c43d3e42-7e63-47f3-bb63-b58a897c29a6
(integer) 1
(1.78s)
127.0.0.1:6379[3]> info memory
# Memory
used_memory:4145366968
used_memory_human:3.86G
used_memory_rss:4375691264
used_memory_peak:8865352096
used_memory_peak_human:8.26G
used_memory_lua:37888
mem_fragmentation_ratio:1.06
mem_allocator:jemalloc-3.2.0
Thanks.
Upvotes: 1
Views: 960
Reputation: 22906
DEBUG OBJECT
shows you the serializedlength of the object. It's the size of the serialized data when saving the object on disk in RDB format. It's NOT the size of the object in memory.
When saving data on disk, Redis might compress the data. So normally, the serialized length is smaller than the size of the in-memory object.
Upvotes: 6