Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase heap size in m2e Eclipse plugin

How does one increase the heap size of the m2e Eclipse plugin? Basically, I'm trying to run an automated integration test using Cargo and Selenium under STS (SpringSource's version of Eclipse) with pre-installed m2e (the popular Maven plugin for Eclipse).

Whenever I run

mvn verify

I get the infamous java.lang.OutOfMemoryError: Java heap space... 63M/63M. So I made some research first. Increase the memory via MAVEN_OPTS, Eclipse.ini / STS.ini, Run Configurations, and even via the Maven plugins thru the pom.xml. Nothing changed. Same error and same amount of memory 63M/63M.

I know my project works. The POM is correct. Why? Because when I run the same command using a stand-alone Maven. The integration test with Selenium and Cargo works. In fact here's the latest output (3 minutes ago):

[INFO] [beddedLocalContainer] Jetty 8.x Embedded is stopped
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 minutes 24 seconds
[INFO] Finished at: Wed Oct 26 14:08:16 CST 2011
[INFO] Final Memory: 70M/149M
[INFO] ------------------------------------------------------------------------

I'm not asking how to increase the memory in stand-alone Maven command. I'm specifically asking how to increase the heap size for m2e.

Note: By default the m2e Eclipse plugin does not have shortcut to the "verify" goal. You have to create a new one via Run Configuration (which does not have an Args tab, fyi).

like image 241
krams Avatar asked Oct 26 '11 06:10

krams


People also ask

How do I increase the heap size available to Eclipse?

Since Eclipse is a Java program, you can increase the heap size of Eclipse by using JVM memory options -Xms and -Xmx. There are two ways to provide JVM options to eclipse either updating the Eclipse shortcut or adding -vmargs on eclipse. ini file.

How do I see heap memory in Eclipse?

Measuring the memory usage of eclipseGoto Window > Preferences > General and enable Show heap status and click OK.


2 Answers

When working with the Maven 2 plugin, setting java options in eclipse.ini or MAVEN_OPTS environment variable will have no effect on your build. You need to add some command line args via the "Edit Configuration and launch" dialog in Eclipse.

"Run As" > "Maven Build", click on the "JRE" tab, enter VM args e.g.

-Xms128M -Xmx512M

like image 165
crasp Avatar answered Sep 27 '22 17:09

crasp


As a follow-on to the already accepted answer, when you invoke "mvn" on the command-line, you are really invoking the mvn.bat (or mvn.sh) wrapper script. It is this wrapper script that uses the MAVEN_OPTS env variable when kicking off the actual maven jvm.

m2e, on the other hand, wants more control over how the maven jvm is kicked off, so it does this directly without the wrapper. This is why you add your memory settings directly to your m2e run/debug configuration VM arguments, rather than using MAVEN_OPTS.

If you want m2e to pass what you already have in MAVEN_OPTS to the maven jvm, in the "Edit Configuration and launch" dialog in Eclipse:

"Run As" > "Maven Build", click on the "JRE" tab, enter VM args e.g.

${env_var:MAVEN_OPTS}
like image 31
vacao Avatar answered Sep 27 '22 18:09

vacao