Increase Java JVM Heap Memory Size on OS X with Maven
If you’re using terminal in conjunction with Maven, the easiest way to increase the heap size on your JVM using OS X is as follows:
1) Using Sudo mode, open up you bash profile (mine lives at ‘/etc/profile’)
2) Add “MAVEN_OPTS=’-Xms256M -Xmx512M’; export MAVEN_OPTS;”
3) Save your profile.
4) Open a new shell and ensure the MAVEN_OPTS var exists by using the “set” command and searching for MAVEN_OPTS.
5) Enjoy your java.
Peace!
Nikolaus said,
April 10, 2009 at 5:56 pm
Hello, I have added the following to profile…
MAVEN_OPTS=”-Xms256M -Xmx512m”; export MAVEN_OPTS;
and when I open a new shell I just get…
-bash: -Xmx512m?: command not found
and I cannot find it in the set, do you know what may be happening?
cheers,
Nikolaus
cs44 said,
April 10, 2009 at 9:13 pm
I’ve updated the original post – note that double quotes around “-Xms256M -Xmx512M” has been changed to single quotes as per this explanation of the meaning of quote type in BASH:
http://www.wiredrevolution.com/bash-programming/single-versus-double-quotes-in-bash
Nikolaus said,
April 10, 2009 at 10:10 pm
Thanks you Chad for your help,
It seems that it is best to copy and paste the code into an editor like pico so that the encoding does not affect it. I used text edit on the first go, without success, so good luck and it seems to have worked great, thanks for the quick fix!