I am running centos 6.4 with 2.6.32-358.6.2.el6.x86_64 which is actually running as a xen vm with
ram 2 GB
On this i have set
cat /proc/sys/vm/overcommit_memory
2
But when i try to start my java application its showing
java.io.IOException: Cannot run program "/bin/bash": java.io.IOException: error=12, Cannot allocate memory
Caused by: java.io.IOException: java.io.IOException: error=12, Cannot allocate memory
But actually this machine has 1.5 gb free memory.
when i set
echo 0 > /proc/sys/vm/overcommit_memory
Everything is working fine,
i thought over committing memory allow me to use more virtual ram(swap+real ram),but why its failing even with more free real ram.
fork()it will need twice the memory even if the memory is never actually used thanks to COW (Copy on Write). To workaround the problem you either setovercommit_ratioto higher to 100 (in which case you're in reality allowing limited overcommitting) or increase swap space a lot. The "correct" value forovercommit_ratiowill depend on your workload and there're no "safe" value higher than 100. – Mikko Rantalainen Jan 08 '18 at 16:37grep Committed_AS /proc/meminfowhich should give you some idea how much the system has already granted memory allocations. That may be a lot more than RAM+swap if you allow overcommit. I'm currently running Committed_AS around 30 GB and the system has 16 GB of RAM and 8 GB swap on SSD. – Mikko Rantalainen Jan 08 '18 at 16:39