I would like Redis to return some memory. I lowered the maxmemory by 10GB but noticed Redis is still "holding onto it" in RSS based on "used_memory_rss". Based on http://redis.io/topics/memory-optimization, it looks like Redis won't return the memory to the OS. How do I force this? Is there any way to do this without restarting Redis?

  • 1
    If you want a database server to be efficient, you shouldn't expect it to give acquired memory back. Usually the database size is much than the onboard memory, so the server needs all the memory it can get. I've never worked with this specific platform; nevertheless, I find Redis's "holding onto it" a perfectly normal phenomenon. – Andriy M Sep 16 '16 at 6:38

I had the same problem and this answer was helpful.

even though Redis isn’t using the memory anymore, the allocator just hasn’t released the memory back to the OS yet. Reds v4 has a MEMORY PURGE command to tell the allocator to release the memory it isn’t using, but unfortunately that isn’t available to you on v3.2.


It is possible to reconfigure redis on the fly but it won't re-read the config file until the next restart. To do this you have to use the CONFIG command to change the value.

Snippet from http://redis.io/topics/config

Changing Redis configuration while the server is running It is possible to reconfigure Redis on the fly without stopping and restarting the service, or querying the current configuration programmatically using the special commands CONFIG SET and CONFIG GET Not all the configuration directives are supported in this way, but most are supported as expected. Please refer to the CONFIG SET and CONFIG GET pages for more information. Note that modifying the configuration on the fly has no effects on the redis.conf file so at the next restart of Redis the old configuration will be used instead. Make sure to also modify the redis.conf file accordingly to the configuration you set using CONFIG SET. You can do it manually, or starting with Redis 2.8, you can just use CONFIG REWRITE, which will automatically scan your redis.conf file and update the fields which don't match the current configuration value. Fields non existing but set to the default value are not added. Comments inside your configuration file are retained.

CONFIG SET details

If that doesn't work and you have a slave you could play a shell game with them and reduce the memory on the slave, restart it, promote that to the master and reduce the memory on the original master and restart it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.