From c1ef6ffe8a53e573b6b9e8d1a02c35e2c62cdad8 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 6 Feb 2012 16:35:43 +0100 Subject: [PATCH] Also remove size of AOF buffers from used memory when doing the math for freeMemoryIfNeeded() --- src/redis.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/redis.c b/src/redis.c index 7b023dc5..4b9ba618 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1802,8 +1802,8 @@ int freeMemoryIfNeeded(void) { size_t mem_used, mem_tofree, mem_freed; int slaves = listLength(server.slaves); - /* Remove the size of slaves output buffers from the count of used - * memory. */ + /* Remove the size of slaves output buffers and AOF buffer from the + * count of used memory. */ mem_used = zmalloc_used_memory(); if (slaves) { listIter li; @@ -1819,6 +1819,10 @@ int freeMemoryIfNeeded(void) { mem_used -= obuf_bytes; } } + if (server.aof_state != REDIS_AOF_OFF) { + mem_used -= sdslen(server.aof_buf); + mem_used -= sdslen(server.aof_rewrite_buf); + } /* Check if we are over the memory limit. */ if (mem_used <= server.maxmemory) return REDIS_OK; -- 2.45.2