Maven - Failed to reserve enough space for object heap error

I am Maven to create my Java project. After several successful builds, I get 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 uses, I added the following line as the first line

 export MAVEN_OPTS=-Xmx512m 

I am still getting the error.

Can someone suggest a fix?

+8
maven jvm
source share
10 answers

The solution was to install forkMode for maven-surefire-plugin like never before. It seems that when the tests are executed, maven is sure that the fire spawns a new JVM. Setting this option never fixed the problem.

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.7.2</version> <configuration> **<forkMode>never</forkMode>** <argLine>-Xms1024m -Xmx1024m -XX:MaxPermSize=2048m</argLine> <systemPropertyVariables> <user.name>${user.name}</user.name> </systemPropertyVariables> </configuration> </plugin> 
+15
source share

I had the same problem and thought Maven was not using the correct jvm. You can check it with

 mvn -version 

In my case, the jvm specified in my JAVA_HOME and PATH was wrong: I used x86 jdk 6 instead of x64 jdk 7. Fixing this resolved the issue.

+11
source share

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

Try installing it below, since Maven only starts if it can reserve all the space. I had this problem and I could solve it as described.

+2
source share

Switching to MAVEN_OPTS = -Xmx512m helped me on 64-bit Windows.

+2
source share

Try setting the variable: MAVEN_OPTS = -Xmx512m -XX: MaxPermSize = 128m

+1
source share

As Didier L said above

This was exactly the problem that I encountered, we used the x86 JVM instead of 64-bit ...

It fixed my problem when I switched to 64-bit JVM.

0
source share

The IntelliJ IDE IDEA has a setting on Maven -> Runner to use a specific JVM. The default for me was to use the JRE, not the JDK set to JAVA_HOME. Be sure to check this setting. As soon as I switched to using JAVA_HOME, everything was fine.

0
source share

I tried it, and its work for me -

maven version -3.2.5 java version -jdk1.7.0_10

-Xmx600m -XX: PermSize = 256 m

0
source share

Try Java 64 bits and configure java_home to this Java 64. obs: javac -version and mvn -version you need to return this Java 64.

0
source share

I ran into this problem when I tried to create the Cloudera Navigator SDK examples. I am using a 32-bit JVM, and the compilation seems to have gone fine, but after that the test failed with this error:

 Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap 

I tried to set MAVEN_OPTS = -Xmx512m, but that didn’t affect it - it is not with the same message. Even the 2097152KB value in the error message was the same (weird!).

I finally realized that the heap size value was hard-coded for the test in the pom.xml file! He had

 <argLine>-Xmx2048m ... </argline> 

I edited pom.xml and changed it to -Xmx1024m, and then maven was able to build and test everything without problems.

So, the lesson is that if you are building something provided to you by someone else (e.g. Cloudera) and you get such an error, check pom.xml carefully to check.

Fyi. I think that using a 64-bit JVM could also solve this problem, but I cannot switch to 64-bit. We have something else we need for this to work, and says that it only works with the 32-bit JVM (I can't explain in more detail than here).

0
source share

All Articles