Can’t save in background: fork: Cannot allocate memory
Redis Log - Can’t save in background: fork: Cannot allocate memory
[root@cloudolife /root]# tail -f /var/log/redis/redis.log
In traditional way, Linux gives you three options for what happens when a process tries to allocate some more memory, controlled by the value of the
The kernel gives you the memory unless it thinks you would clearly overcommit the system (mode 0, the default, ‘heuristic overcommit’).
the kernel always gives you the memory (mode 1, ‘always overcommit’).
the kernel refuses to give you more memory if it would take the committed address space over the commit limit (mode 2, what I call ‘strict overcommit’).
(Disclaimer: all of this assumes a relatively recent 2.6 kernel.)
These settings control how Linux handles virtual memory limits.
After changing this setting from
1 Redis started persisting the data immediately and the overall performance increased dramatically.
To do so either open the file
/proc/sys/vm/overcommit_memory and remove 0 and put 1 or run the following command.
This might now work as the file may be already in use by the system.
echo 1 > /proc/sys/vm/overcommit_memory
So other way to do the same is to add
vm.overcommit_memory = 1 to
/etc/sysctl.conf and then reboot or run the command
sysctl vm.overcommit_memory=1 for this to take effect.
$ vi /etc/sysctl.conf