Direct Answer
MEMORY PURGE in Redis 7.0 does not target specific data types. It asks the underlying memory allocator (jemalloc or tcmalloc) to return already-free memory chunks to the operating system. The command operates at the allocator level, so strings, lists, hashes, sets, and sorted sets are all treated identically—only memory the allocator has already released from active Redis objects can be purged.
Confirmed Behavior
- The command never frees memory still referenced by any Redis data structure.
- It works with both jemalloc and tcmalloc in Redis 7.0, but the amount of memory returned depends on each allocator's purge implementation.
- Running it on a busy instance can cause latency spikes because the allocator may scan internal structures to reclaim memory.
- Logical data set is unchanged; only the resident set size (RSS) reported by the OS may decrease.
- Fragmentation metrics may temporarily rise during the purge before the allocator consolidates free space.
Likely Explanation for Community Reports
Differing results for hashes and sets likely reflect allocator state at purge time, not data-type selectivity. If a hash or set was recently modified or deleted, its memory may still be held in the allocator's free lists and become eligible for purge. Conversely, active data structures of any type retain their memory.
Verification Procedure (Controlled Environment)
- Run
INFO memory and record baseline used_memory_rss and mem_fragmentation_ratio.
- Execute
MEMORY PURGE.
- Run
INFO memory again; a decrease in used_memory_rss indicates memory was returned to the OS.
- Use
MEMORY STATS before and after to observe changes in fragmentation fields.
- Optionally monitor
redis-cli --latency during the purge to detect latency spikes.
One Diagnostic Detail Needed
Which allocator is your Redis build using (jemalloc or tcmalloc)? Check with INFO memory | grep allocator. The purge effectiveness differs between them, and tcmalloc builds without a purge routine will make the command a no-op.