How to fix maven Out of Memory issue

Filed Under: Java

Recently I started working on a huge project that was using Maven as a build and deployment tool. When I tried to build the project, I got the ugly java.lang.OutOfMemoryError.

To fix this, you will have to increase the maven heap size memory, good thing is that it can be done easily by using maven options.

export MAVEN_OPTS=-Xmx1024m

Above command will increase the memory for maven and your build should be going fine.

If you run the export command on terminal, then it’s valid for that session only. So if you want Maven to run with this option always, you should include it in your user profile. For example .bash_profile in Mac OS.

Note that export command syntax is different on different operating systems, so use the syntax that is correct for your OS.

Leave a Reply

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

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages