title: Java on CentOS : not enough memory
body: <p>When I make a command in PHP like:</p>
  
  <pre><code>exec('java -version &gt; test.txt');
  </code></pre>
  
  <p>the file test.txt is created but with an error inside :</p>
  
  <blockquote>
    <p>There is insufficient memory for the Java Runtime Environment to
    continue.</p>
    
    <p>Native memory allocation (mmap) failed to map 2555904 bytes for
    committing reserved memory.</p>
  </blockquote>
  
  <p>An error report file with more information is saved as:
  <code>/tmp/hs_err_pid25505.log</code></p>
  
  <p>The error report file <strong>does not exist</strong> at this location.</p>
  
  <p>When I try to execute the same command in the shell window, it works:</p>
  
  <p><code>openjdk version "1.8.0_101"</code></p>
  
  <blockquote>
    <p>OpenJDK Runtime Environment (build 1.8.0_101-b13)   OpenJDK 64-Bit
    Server VM (build 25.101-b13, mixed mode)</p>
  </blockquote>
  
  <p>The command i'm trying to execute is actually not <code>java -version</code> but a more complicated one. However, the result is the same.</p>
  
  <p>I think the problem comes from PHP.
  Until now I have tried to increase memory_limit but to no avail.
  I've seen people having similar problems but the solutions proposed don't work.</p>