Results 1 to 3 of 3
Thread: Out of Memory Error???
- 03-25-2012, 08:18 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 4
- Rep Power
- 0
Out of Memory Error???
So, I've been trying to make a game with lwjgl, and have been using slick for the textures and texture loaders. For some reason, whenever I start up the game and it goes for maybe thirty seconds, it doesn't respond, and then terminates itself, giving the error:
Exception in thread "main" java.lang.OutOfMemoryError
at sun.misc.Unsafe.allocateMemory(Native Method)
at java.nio.DirectByteBuffer.<init>(Unknown Source)
at java.nio.ByteBuffer.allocateDirect(Unknown Source)
at org.lwjgl.BufferUtils.createByteBuffer(BufferUtils .java:60)
at org.newdawn.slick.opengl.PNGImageData.loadImage(PN GImageData.java:692)
at org.newdawn.slick.opengl.CompositeImageData.loadIm age(CompositeImageData.java:62)
at org.newdawn.slick.opengl.CompositeImageData.loadIm age(CompositeImageData.java:43)
at org.newdawn.slick.opengl.InternalTextureLoader.get Texture(InternalTextureLoader.java:277)
at org.newdawn.slick.opengl.InternalTextureLoader.get Texture(InternalTextureLoader.java:231)
at org.newdawn.slick.opengl.InternalTextureLoader.get Texture(InternalTextureLoader.java:184)
at org.newdawn.slick.opengl.TextureLoader.getTexture( TextureLoader.java:64)
at org.newdawn.slick.opengl.TextureLoader.getTexture( TextureLoader.java:24)
at graphicsgame.RenderMap.setMap(RenderMap.java:21)
at graphicsgame.RenderScreen.renderState(RenderScreen .java:169)
at graphicsgame.RenderScreen.update(RenderScreen.java :55)
at graphicsgame.RenderScreen.start(RenderScreen.java: 33)
at graphicsgame.GraphicsGame.main(GraphicsGame.java:8 )
It isn't the problem with the amount of memory i have because i can play stuff like minecraft which uses a ton, and that works just fine. The way that I've been loading the textures so far is like this:
try {
zombie = TextureLoader.getTexture("PNG", new FileInputStream(new File("res/zombie.png")));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
and that's where the exact error in the lines come up. Any ideas?
Thanks
-Pfolder
- 03-25-2012, 09:32 PM #2
Re: Out of Memory Error???
Try doing some debugging to see what is using up memory. The Runtime class has some methods that return memory amounts. Try printing some of them in different parts of the code.
Use the java command's -XProf option to get a trace of what code is executing. You may need to add some special code to exit the program before it throws the exception.If you don't understand my response, don't ignore it, ask a question.
- 03-26-2012, 11:56 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,480
- Rep Power
- 16
Re: Out of Memory Error???
The Minecraft launcher will define how mch memory it needs (using an -Xmx switch).
If you don't use that then the fact Minecraft works is irrelevant to your problem, which is entirely down to the amount of memory Java has available to it and the amount you are asking it to use.
Now, that is not to say you don't have a memory leak.
Are you loading a lot of images?
Is this the only image you are loading?
Are you holding onto multiple copies of the same image, when you possibly only need the one?
All these need to be looked into by you.Please do not ask for code as refusal often offends.
Similar Threads
-
out of memory error
By aahadqj in forum Threads and SynchronizationReplies: 5Last Post: 12-07-2010, 03:40 PM -
java out of memory error-heap space error
By elsanthosh in forum NetBeansReplies: 4Last Post: 06-15-2010, 09:31 AM -
Out of memory Error
By monika in forum Advanced JavaReplies: 10Last Post: 03-16-2010, 05:03 PM -
Out of memory error
By Mrs. Deswal in forum Threads and SynchronizationReplies: 3Last Post: 07-30-2009, 03:27 AM -
Low memory error
By rlhs76 in forum New To JavaReplies: 2Last Post: 02-08-2008, 10:25 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks