Reputation: 419
because something unexpected accidents redis memory has increased up a lot , and we delete the unused keys a lot , but the memory does not release, is there a way to manually release it, except restart of redis.
redis info
# Memory used_memory:14166381000 used_memory_human:13.19G used_memory_rss:41278218240 used_memory_peak:50044293760 used_memory_peak_human:46.61G used_memory_lua:31744 mem_fragmentation_ratio:2.91 mem_allocator:jemalloc-3.2.0
nmon t
│ Top Processes Procs=288 mode=3 (1=Basic, 3=Perf 4=Size 5=I/O)──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│ │ PID %CPU Size Res Res Res Res Shared Faults Command │ │ Used KB Set Text Data Lib KB Min Maj │ │ 1732 15.9 58932952 40309580 756 58921404 0 944 9 0 redis-server
free -m total used free shared buffers cached Mem: 64378 61914 2464 0 11 22 -/+ buffers/cache: 61879 2498 Swap: 32255 16710 15545
Upvotes: 2
Views: 1636
Reputation: 4849
According to antirez https://groups.google.com/forum/#!topic/redis-db/ibhYDLT_n68 (1st answer) Redis would always use used_memory_peak as a reference to how much memory it might need (and how much memory it wants allocated).
If you really need to free that memory with zero downtime — you can setup a slave, make it read-write CONFIG SET slave-read-only no
reroute your application traffic to the slave and restart the master. Or just continue using the slave (by making it master SLAVEOF NO ONE
)
Upvotes: 2