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






beyondwork said
this is wrong.
export MAVEN_OPTS=-Xmx512m
above is the right way of doing. you should not use double Quotes.
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?
Chandan Benjaram said
Thanks. Both of these options working on my Mac X 10.5.
-Chandan Benjaram
Upekha said
it works
Akila said
I’m using maven 2.0.6 on the ubuntu system. It worked for me without quotes. Thanks.
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.
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.
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