image - How do I fix "java.lang.OutOfMemoryError at sun.misc.Unsafe.allocateMemory(Native Method)"? -


I am a Java application that uses the library to load images. However, on some computers, I get this error when the program is trying to run:

  formula exception "main" java.lang.OutOfMemoryError on sun.misc.Unsafe.allocateMemory (Native resident method). Init & gt; (DirectByteBuffer.java:99) Org on java.nio.DirectByteBuffer organization on java.nio.ByteBuffer.allocateDirect (ByteBuffer.java:288) org.lwjgl.BufferUtils.createByteBuffer (BufferUtils.java:60) & lt. newdawn.slick.opengl.CompositeImageData.loadImage (CompositeImageData Java: 43)  

I VM options:

 -Djava.library.path = lib -Xms1024M -Xmx1024M -XX: PermSize = 256M -XX: MaxPermSize = 256M 

the program some large images in the beginning (1024 x 768 resolution) loads.

Any help to solve this problem would be greatly appreciated.

Op = "text">

Just indicates that the JVM has gone out of memory The first line of the stacktrace is actually relevant here it just happens as "not" by chance actually there where you run out of memory with JVM collect all the garbage in vain, initially.

There are basically two solutions:

  1. Provide more memory.
  2. Fix memory leaks and / or assign less memory to the code (i.e., the code is more efficient, very long and so similar) to the large byte [] Like the memory does not get hold of expensive resources.

Point 1 is easy to do but is not always a solution, if it is apparently the leakage of memory in the code, point 2 is best to move down with A.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -