Out of heap space when moving project to a different computer?


I've got a java project I'm working on in Eclipse, and I worked on one machine for a while but needed to bring things to another machine. I used the default settings on both, and both machines are plenty capable of running the program I'm working on. For some reason, though, when I tried to build and run on the new machine it gave me this error

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space

After some googlework I found out some of the possible causes of this, but even after several changes I cannot get it to work. The real puzzler here is that it does work with the same settings on a different computer.

Why would it be doing this?

(I just added the argument "-Xmx1024M" under Window->Preferences->Java->JRE which fixed it, but I'm still wondering why it would have happened in the first place.)

As stated in the question How is the default java heap size determined?, the default value for the -Xmx parameter depends on the machine (for example, on its OS and installed memory).

So the default value on the machines are probably different, and the lower one of them is just too low for your program.

This video can help you solving your question :)
By: admin