title: Java OutofMemory Error in Ubuntu Even if enough memory available
body: <p>I have a VPS with 20GB RAM, Ubuntu OS. I am trying to allocate 10GB RAM as the maximum heap to java using JAVA_TOOL_OPTIONS but I couldn't. Please see the attached screenshot. It shows available memory as 17GB. Its working when I try to set to 7GB. But heap error occurs only when it is > 7GB. I have already installed glassfish and allocated 3Gb to its cluster. Its working fine. But why I am not able to allocate greater than 7GB when I have 17GB RAM free.</p>
  
  <p><a href="https://i.stack.imgur.com/pQ9OA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pQ9OA.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/l1ZPz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l1ZPz.png" alt="enter image description here"></a></p>
  
  <p><strong>TOP</strong>
  <a href="https://i.stack.imgur.com/S7IJe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S7IJe.png" alt="enter image description here"></a></p>
  
  <p><strong>ULIMITS</strong></p>
  
  <p><a href="https://i.stack.imgur.com/znQhF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/znQhF.png" alt="enter image description here"></a></p>
  
  <p><strong>Java -version</strong>
  <a href="https://i.stack.imgur.com/LHc1b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LHc1b.png" alt="enter image description here"></a></p>
  
  <p><strong>OverCommit memory</strong></p>
  
  <p><a href="https://i.stack.imgur.com/d9q77.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d9q77.png" alt="enter image description here"></a></p>
  
  <p><strong>My Hardware is Virtual Hosted. Below is the configuration</strong></p>
  
  <ul>
  <li>Architecture: x86_64</li>
  <li>CPU op-mode(s): 32-bit, 64-bit</li>
  <li>Byte Order: Little Endian</li>
  <li>CPU(s): 16</li>
  <li>Vendor ID: GenuineIntel</li>
  <li>CPU family: 6</li>
  <li>Model: 26</li>
  <li>Stepping: 5</li>
  <li>CPU MHz: 2266.802</li>
  <li>BogoMIPS: 4533.60</li>
  <li>Virtualization: VT-x</li>
  </ul>