Increase heap size in m2e Eclipse plugin

38,073

Solution 1

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

Solution 2

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}

Solution 3

You can add in your pom.xml your memory settings:

<plugin>
 <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    ...
    <fork>true</fork>
    <meminitial>128m</meminitial>
    <maxmem>512m</maxmem>
    ...
  </configuration>
</plugin>

The description of all maven-compiler-plugin parameters is here: link

Share:
38,073
krams
Author by

krams

I'm a full-time Java/Spring developer on the backend and jQuery/HTML5 developer on the frontend. Visit my blog at http://krams915.blogspot.com

Updated on July 12, 2022

Comments

  • krams
    krams almost 2 years

    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).

  • krams
    krams over 12 years
    Yes, I did. But that didn't affect the m2e plugin. It did affect though the stand-alone Maven plugin.
  • KyelJmD
    KyelJmD almost 11 years
    is there anyway we can permanently add this configuration to m2e? so that we wouldn't have to type on every run?/build?
  • crasp
    crasp almost 11 years
    Yes, you can add them via Eclipse > Preferences > Maven > Installations > "Global settings for embedded installation". There you can point to your maven settings outside Eclipse.
  • nclark
    nclark over 8 years
    In JBoss Developer Studio 8.1.0.GA, Preferences > Maven > Installations shows two Maven Installations: EMBEDDED and WORKSPACE. They are both grayed out, as is the Edit... button.