2
votes

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

1
Peak means "the greatest amount of memory that was used in the past". The "used" figures indicate how much is actually used. The peak number will never go down.hobbs
yes, I know redis peak memory mean, such as free -m and nmon was showing, the memory was eaten to much by redis , but in fact the data is far less as showing ,as you can see ,memory has been swapout already, so I hope there is a way to release somemk_

1 Answers

2
votes

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)