Maven - Could not reserve enough space for object heap error

Viewed 32875

I am Maven to build my Java project. After several successful build, I am now getting the following error:

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

In my maven.sh file that my build is using, I have added the following as the first line

export MAVEN_OPTS=-Xmx512m

I am still getting the error.

Can anyone suggest a fix?

10 Answers

I had the same issue and I figured Maven was not using the right jvm. You can check this with

mvn -version

In my case, the jvm specified in my JAVA_HOME and PATH was incorrect: I was using an x86 jdk 6 instead of an x64 jdk 7. Fixing this solved the issue.

I think you want to reserve more space than you have, with your settings: MAVEN_OPTS=-Xmx512m

Try to set it lower, since Maven starts only if it can reserve the whole space. This problem occurred to me and I could solve it like described.

Related