Ouf of Heap Space After Compile

Hi there,

I’m getting a strange error when clicking a .jar file after compiling.

My project works just fine when running in the SDK but after compiling and clicking the jar I get java lang:Out of heap space error.

I can’t imagine what I did to cause this or what the problem could be. I’ve tried to build a few times but this error keeps happening… It started fairly randomly

It seems you are running out of heap space when you run your application. Did you by any chance setup some runtime options for when running in the SDK?

It’s pretty common to have increased the heap size there but those won’t be carried over to the jar.

I don’t believe I did pspeed.

It is a fairly small game and I can’t understand why this would happen like this. I had someone else run the .jar file and they had the same issue and ran out of space too…

It was working properly before and I had not added anything, and actually is much smaller than previous versions of the game that had run…

The entire size is approximately 25mb.

EDIT: This game also runs fine on android… It would seem strange if my tablet had more heap space than my pc. But I’m not good with this stuff

What does stack trace say?

There is no stack trace, exactly the only thing it says is

“Uncaught exception thrown in Thread[LWJGL Render Thread, 5, main]
OutOfMemoryError:Java HeapSpace”

EDIT: Solved with a Batch file

“C:\Program Files\Java\jre7\bin\java.exe” -Xms1024M -Xmx4096M -jar MyGame.jar

Is there a way to do this from within the .jar

I have little knowledge of .bat files and this was more of a lucky solution…

No. And you must have added these command line options in the SDK or you’d likely get the error also.

The way you distribute an app with these settings is to add them to your project properties as run command line arguments and then generate an EXE. The EXE will have the parameters embedded. Jars have no such mechanism.