title: How to solve "java.io.IOException: error=12, Cannot allocate memory" calling Runtime#exec()?
body: <p>On my system I can't run a simple Java application that start a process. I don't know how to solve. </p>
  
  <p>Could you give me some hints how to solve?</p>
  
  <p>The program is:</p>
  
  <pre><code>[root@newton sisma-acquirer]# cat prova.java
  import java.io.IOException;
  
  public class prova {
  
     public static void main(String[] args) throws IOException {
          Runtime.getRuntime().exec("ls");
      }
  
  }
  </code></pre>
  
  <p>The result is:</p>
  
  <pre><code>[root@newton sisma-acquirer]# javac prova.java &amp;&amp; java -cp . prova
  Exception in thread "main" java.io.IOException: Cannot run program "ls": java.io.IOException: error=12, Cannot allocate memory
          at java.lang.ProcessBuilder.start(ProcessBuilder.java:474)
          at java.lang.Runtime.exec(Runtime.java:610)
          at java.lang.Runtime.exec(Runtime.java:448)
          at java.lang.Runtime.exec(Runtime.java:345)
          at prova.main(prova.java:6)
  Caused by: java.io.IOException: java.io.IOException: error=12, Cannot allocate memory
          at java.lang.UNIXProcess.&lt;init&gt;(UNIXProcess.java:164)
          at java.lang.ProcessImpl.start(ProcessImpl.java:81)
          at java.lang.ProcessBuilder.start(ProcessBuilder.java:467)
          ... 4 more
  </code></pre>
  
  <p>Configuration of the system:</p>
  
  <pre><code>[root@newton sisma-acquirer]# java -version
  java version "1.6.0_0"
  OpenJDK Runtime Environment (IcedTea6 1.5) (fedora-18.b16.fc10-i386)
  OpenJDK Client VM (build 14.0-b15, mixed mode)
  [root@newton sisma-acquirer]# cat /etc/fedora-release
  Fedora release 10 (Cambridge)
  </code></pre>
  
  <p><strong>EDIT: Solution</strong> 
  This solves my problem, I don't know exactly why:</p>
  
  <p>echo 0 > /proc/sys/vm/overcommit_memory</p>
  
  <p>Up-votes for who is able to explain :)</p>
  
  <p>Additional informations, top output: </p>
  
  <pre><code>top - 13:35:38 up 40 min,  2 users,  load average: 0.43, 0.19, 0.12
  Tasks: 129 total,   1 running, 128 sleeping,   0 stopped,   0 zombie
  Cpu(s):  1.5%us,  0.5%sy,  0.0%ni, 94.8%id,  3.2%wa,  0.0%hi,  0.0%si,  0.0%st
  Mem:   1033456k total,   587672k used,   445784k free,    51672k buffers
  Swap:  2031608k total,        0k used,  2031608k free,   188108k cached
  </code></pre>
  
  <p>Additional informations, free output: </p>
  
  <pre><code>[root@newton sisma-acquirer]# free
               total       used       free     shared    buffers     cached
  Mem:       1033456     588548     444908          0      51704     188292
  -/+ buffers/cache:     348552     684904
  Swap:      2031608          0    2031608
  </code></pre>