Maven Runs out of Memory

Maven 1.0 has some problems with memory leaks. Most of the time these aren’t issues, but if you are trying to compile a multiproject you might run into problems. By default Maven tells java to let it have up to 256MB of ram. If you need to increase this you’ll need to open the maven.bat (windows) or maven.sh (unix) file and change the way that java is called. Somewhere around line 118 (on the .bat file)you should see the following:

if "%MAVEN_OPTS%"=="" SET MAVEN_OPTS="-Xmx256m"

Change the line so it reads:

if "%MAVEN_OPTS%"=="" SET MAVEN_OPTS="-Xmx1000m"

This will give Maven 1GB of memory to work with. While this doesn’t really solve the problem of the memory leak, it may give you enough space to keep the problem from crashing Maven.

You can also set MAVEN_OPTS by setting it up as a variable in your environment. If you do this the environment will override anything you set in the .bat or .sh file.

About 

Leave a Reply

Your email address will not be published. Required fields are marked *