2

I recently came upon a SO question where the op asked in which scenarios redis frees up memory. It seems they were recommended a hard start is a potential way, however this is untested in the case of redis. Can anyone let me know for sure whether this works?

I have a live environment, I don't want to have to restart redis-server, but its memory foot print is debilitating now and I'm on the verge of a server migration. So it's important for me to remove as much bloat as possible (and there's a ton of bloat).

Hassan Baig
  • 15,055
  • 27
  • 102
  • 205

1 Answers1

4

I'm not sure what you mean by "bloat", but attaching your server's INFO ALL output may be helpful.

By default, Redis uses jemalloc as a memory allocator. The allocator is in charge of actually freeing RAM for the OS to reclaim, after Redis frees it. Redis v4 and above include the ability to force the allocator to purge the freed RAM (MEMORY PURGE, see https://github.com/antirez/redis-doc/pull/851).

Regardless of purge, there's also the matter of memory fragmentation. While v4 has the experimental active defrag feature, a restart is the way to "fix" that in prior versions.

To mitigate a restart and the downtime involved, use Redis' replication to create a slave and failover your apps to it before restarting the original master.

Itamar Haber
  • 47,336
  • 7
  • 91
  • 117