Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
It sounds like you already have a perfectly fine solution: Disable overcommit and make Linux behave like Unix. As a side benefit this spares you from the OOM killer. –  voretaq7 Jun 4 '13 at 15:14
    
i dont need over commit,but this error forced me to check over commit and it was already enabled.so i am looking for the reason for this behaviour. –  Kevin Parker Jun 4 '13 at 15:20

1 Answer 1

up vote 2 down vote accepted

From this guide:

2 — The kernel fails requests for memory that add up to all of swap plus the percent of physical RAM specified in /proc/sys/vm/overcommit_ratio. This setting is best for those who desire less risk of memory overcommitment.

If you have less than 2 GB of swap, then the kernel will deny the request if overcommit_ratio is set too low. Having it set to "1" allows overcommitting and is good for performance.

share|improve this answer
    
can u please elaborate,my commit_ratio is 80% and swap is 512 –  Kevin Parker Jun 4 '13 at 15:27
1  
In that scenerio if 1638+512 MB of RAM was requested, it would be just denied. The notes state that it's not recommended to use "2" as your option if you have less swap than RAM. –  Nathan C Jun 4 '13 at 15:29
    
And in my experience Java will gobble up any RAM it can unless specified with -Xms (I think that's the switch), which results in those overcommit errors. –  Nathan C Jun 4 '13 at 15:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.