This site requires JavaScript, please enable it in your browser!
Greenfoot back
ImFerocious wrote ...


Allocating memory?

ImFerocious ImFerocious


I'm making a mining game known as "Project Condor" (temporary name) link- When I'm programming i come across a problem that is kinda time consuming when i try to test just one little change in the code. Every time i compile the scenario in rapid succession i would keep getting an error message saying:
java.lang.OutOfMemoryError: Java heap space
I remember reading faintly that this is caused when the memory allocated to java becomes well full. and i wanted to know how to exactly increase the amount of memory java has access to so that it won't constantly become full. I tried looking at solutions and i found out that: java -Xms64m -Xmx256 (then program name) would do something like add a minimum of 64 megs and a max of 256 megs of memory to that programs available memory and i wanted to know how to make more memory in java available to Greenfoot so i can stop having "java heap space" error
nccb nccb


There is a Java bug that can cause this problem. Some more details with various suggested fixes is available on the bug description. It sounds like upgrading to JDK 7 may avoid the problem, and may be easier than fiddling with the JVM flags.
supermagicmilk supermagicmilk


Go to Greenfoot/lib/ where you should find a file called greenfoot.defs. Open it in a text editor and scroll to the bottom where you should see this line: bluej.vm.args=-Xincgc Add the options to the end here and it should help (like so): bluej.vm.args=-Xincgc -Xms1024M -Xmx1024M I set mine to 1024M because I've got a lot of memory on my computer, but you should set it to something appropriate for your own machine. It doesn't remove the problem, but it makes it come up less frequently.
You need to login to post a reply.