我正在运行本地redis服务器.在redis中有一个坏密钥占用了大量内存.在删除该键之前,"info memory"显示5.3GB作为占用内存.那个坏密钥占用了大约800MB的数据.这基于"调试对象"输出.
删除该密钥后,内存几乎翻了一倍.预计只有800MB左右.
关于这背后是什么的任何想法?在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
Run Code Online (Sandbox Code Playgroud)
谢谢.
DEBUG OBJECT显示对象的序列化长度.以RDB格式将对象保存到磁盘上时,它是序列化数据的大小.它不是内存中对象的大小.
在磁盘上保存数据时,Redis可能会压缩数据.通常,序列化长度小于内存中对象的大小.