Solution:
Root Cause: Linux Kernel Memory Overcommit Heuristic Rejection By default, Linux uses a heuristic memory overcommit algorithm (
vm.overcommit_memory = 0). When Redis initiates background persistence tasks such as
BGSAVE or
BGREWRITEAOF, it executes a
fork() system call to spawn a child process. Although Linux relies on Copy-on-Write (CoW), the kernel evaluates whether sufficient physical RAM is available to satisfy the child process's entire virtual address space. Under heuristic overcommit mode, if free RAM is less than total memory allocated by Redis, the
fork() fails or the kernel Out-Of-Memory (OOM) killer selects the
redis-server process for termination.
Step-by-Step Fix: 1 Check Active Kernel Overcommit Setting:
Run sysctl in terminal: Copy
bash
sysctl vm.overcommit_memory
If the output is vm.overcommit_memory = 0 or 2, overcommit is restricting fork allocations. 2 Enable Memory Overcommit Live:
Apply memory overcommit mode 1 (always overcommit) immediately: Copy
bash
sudo sysctl vm.overcommit_memory=1
3 Persist Overcommit Configuration Across Reboots:
Edit /etc/sysctl.conf or add a drop-in file /etc/sysctl.d/99-redis.conf: Copy
text
vm.overcommit_memory = 1
Reload configuration: Copy
bash
sudo sysctl -p /etc/sysctl.d/99-redis.conf