c0nnexx10n : C0nnect1ng L1fe w1th Techn010gy

Byte by Byte Impressions on Technology, People and Process !

QuickTip : How to increase the Java heap memory for Maven 2 on linux

Posted by Vikas Hazrati on Thursday, July 26, 2007

If you get an error OutOfMemory error while doing mvn site, because of all the reports that you are generating, just increase the heap size for maven2. The way to do that on linux.

In your mvn.sh add this as the first line after the copyright and other comments.

export MAVEN_OPTS=”-Xmx512m”

note than Maven 2.0.6 onwards some users have reported that the double quotes give problems, hence you might want to use

export MAVEN_OPTS=-Xmx512m

9 Responses to “QuickTip : How to increase the Java heap memory for Maven 2 on linux”

  1. beyondwork said

    this is wrong.

    export MAVEN_OPTS=-Xmx512m

    above is the right way of doing. you should not use double Quotes.

  2. vikashazrati said

    Well on my maven 2.0.5 on the ubuntu system, the one with double quotes just works fine. Do you get any error when you use double quotes?

  3. Chandan Benjaram said

    Thanks. Both of these options working on my Mac X 10.5.

    -Chandan Benjaram

  4. Upekha said

    it works

  5. Akila said

    I’m using maven 2.0.6 on the ubuntu system. It worked for me without quotes. Thanks.

  6. Akila said

    Additionally I use Artifactory 1.3.0-beta-5 as well. Later when I was using it I got java.lang.OutOfMemoryError: PermGen space exception . So I added the following command in my mvn.sh (This time with quotes)

    export MAVEN_OPTS=”-Xmx1024M -XX:MaxPermSize=1024m”

    It worked well.

  7. Lee Yates said

    I have tried all of these options on linux and MacOS. While they do not cause errors they do not increase the memory allocated to the process or solve the problem.

    Adding the following to my bash profile does solve the problem

    export MAVEN_OPTS=”-Xmx2048m -XX:MaxPermSize=128m”

    • vikashazrati said

      Thanks for sharing that Lee.

  8. Dominik said

    Hello Vikas,

    couldn’t you integrate all this and update your post? I mean
    - the non-quoted version
    - include the export MAVEN_OPTS=”-Xmx2048m -XX:MaxPermSize=128m” version (which on my Mac OS X doesn’t work, single quotes are required instead)

    Dominik

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>