Commit c1ef6ffe authored by antirez's avatar antirez
Browse files

Also remove size of AOF buffers from used memory when doing the math for freeMemoryIfNeeded()

parent f6b32c14
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment