Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the right way to set JVM param's in eclipse

i am using eclipse 4.2 to execute a junit test. the test uses a lot of memory so what i want to do is to enlarge the memory allocated to the jvm. i wanted to know if there is a differences between setting the heap memory param's in the eclipse ini file and the run configuration?

like image 368
Raven Avatar asked Aug 01 '12 11:08

Raven


3 Answers

Note the memory settings for Java processes started by eclipse are different from the maximum allowed memory size for eclipse itself.

The allowance for eclipse itself is set on startup by

-vmargs -Xmx1024M -Xms1024M -XX:PermSize=2048m -XX:MaxPermSize=2048m

Note that the m in "mx" is case sensitive, while the m in "1024M" is case insensitive; and the single-X options are spelt without "=", but the double-X options are spelt with "=".

The memory size for JVMs started by eclipse, which is what you want to influence unit tests, is set within eclipse:

Window::Preferences::Java::Installed JREs::Edit::Default Vm Arguments: -Xms128M -Xmx2048M

(Exact titles of menu entries may vary by eclipse version.)

like image 167
Kilian Foth Avatar answered Nov 12 '22 04:11

Kilian Foth


you can increase heap size in eclipse.ini file like below.

 -Xms1024m
 -Xmx1024m
 -XX:MaxPermSize=256m
like image 38
amicngh Avatar answered Nov 12 '22 02:11

amicngh


If you set it in eclipse.ini, it applies to the Eclipse process itself - not to any new Java processes you start from Eclipse.

If you set it in the Run Configuration, it only applies to that run configuration, but not to Eclipse itself.

Since your unit test is using a lot of memory, it won't matter how much memory Eclipse has available. The unit test will run in a new Java process, with default memory allocation.

like image 3
mthmulders Avatar answered Nov 12 '22 04:11

mthmulders