title: How do I fix "java.lang.OutOfMemoryError at sun.misc.Unsafe.allocateMemory(Native Method)"?
body: <p>I'm making a Java application that uses the <a href="http://slick.cokeandcode.com/" rel="nofollow noreferrer">Slick</a> library to load images. However, on some computers, I get this error when trying to run the program:</p>
  
  <pre><code>Exception in thread "main" java.lang.OutOfMemoryError 
      at sun.misc.Unsafe.allocateMemory(Native Method) 
      at java.nio.DirectByteBuffer.&lt;init&gt;(DirectByteBuffer.java:99) 
      at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:288) 
      at org.lwjgl.BufferUtils.createByteBuffer(BufferUtils.java:60) 
      at org.newdawn.slick.opengl.PNGImageData.loadImage(PNGImageData.java:692)
      at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:62)
      at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:43)
  </code></pre>
  
  <p>My VM options are:</p>
  
  <pre>-Djava.library.path=lib -Xms1024M -Xmx1024M -XX:PermSize=256M -XX:MaxPermSize=256M</pre>
  
  <p>The program loads a few large images (1024 x 768 resolution) at the beginning.</p>
  
  <p>Any help to solve this problem would be greatly appreciated.</p>