[NoSQL Redis] FAQs Redis
Can’t save in background: fork: Cannot allocate memory
APP log
1 | ${RAILS_ROOT}/log/production.log |
Redis Log - Can’t save in background: fork: Cannot allocate memory
1 | [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 vm.overcommit_memory
sysctl:
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 0
to 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.
1 | 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.
1 | $ vi /etc/sysctl.conf |
See Can’t save in background: fork: Cannot allocate memory Redis ~ Appychip - https://jee-appy.blogspot.com/2016/04/can-not-save-in-background-fork-redis.html to learn more.