Many times we get java.lang.OutOfMemoryError: java heap space while building our project either by using maven or ANT just because heap size is not enough to build the project. At this point we just want to increase the heap size used by ANT or MAVEN and this java tip will let you do this:
How to increase Java Heap size for Maven on Linux/Unix
1. Open your mvn.sh file and add the following line:
export MAVEN_OPTS=-Xmx512m
this will allow to specify java heap space based on your project needs.
How to increase Java Heap space for Maven on Windows
1. go to C:\apache-maven-2.2.1\bin
2. open your mvn.bat file and add the following line :
set MAVEN_OPTS=-Xmx512m
next time you run maven commands like mvn clean or mvn install it will use this heap size.
This article is in continuation of my earlier post on java heap 10 points on java heap space if you haven’ read that you may find some useful info there.
How to increase Java Heap size/space/memory for ANT on Linux/Unix
Similar to Maven you can specify ANT_OPTS to specify JVM specific arguments for ANT build tool. Here is step by step guide to change the java heap space for ANT:
1. Go to ANT_HOME directry (directory where Ant has been installed)
2. Open ant.bat file and add following line on it
export ANT_OPTS=-Xmx512m
some time you may need to put the value –Xmx512M inside double quotes.
3. Done next time you run “ant” it will use modified java heap size and will not throw OutOfMemoryError till the new limit reached.
How to increase Java Heap size/space/memory for ANT on Windows
As shown above for Linux ANT_OPTS can also be used specify JVM specific arguments for ANT in windows. Here is step by step guide to increase the java heap memory for ANT in Windows:
4. Go to ANT_HOME directory (directory where Ant has been installed)
5. Open ant.bat file and add following line on it
set ANT_OPTS=-Xmx512m
some time you may need to put the value –Xmx512M inside double quotes.
6. Done next time you run “ant” it will use modified java heap size and will not throw OutOfMemoryError till the new limit reached.
Tidak ada komentar:
Posting Komentar