I am using 4 VCPUs - 8GB RAM DigitalOcean VM and running 8 to 10 tomcats on it. I have also created 8 GB Swap Space. However, I always get out of memory (OOM ) error and resulting oom-killer to choose and sacrifice some processes, to free up the memory. And that's why I try the following settings to resolve the OOM Killer's behavior and always check, never overcommit memory by modifying the /etc/sysctl.conf file.
vm.overcommit_memory = 2 vm.overcommit_ratio = 100
As per the above memory allocation formula, 100% Swap Space + 100% RAM should be used by the system.
But now I am not able to start some modules and getting error like "Cannot allocate memory". However, Swap space is more than 50% (4 GB) is free.
I would like to know why memory issue error showing even if enough Swap space is free and how to fix it.