My Adventures in Coding

June 15, 2009

mvn clean install – Could not reserve enough space for object heap

Filed under: Maven — Brian @ 5:20 pm
Tags:

If you get the following error, it is most likely that the “Surefire” pluggin does not have enough memory.

Error occurred during initialization of VM
Could not create the Java virtual machine.
Could not reserve enough space for object heap
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.

The solution is to increase the memory for the Surefire pluggin using the command line option:

mvn -Dsurefire.memory="-Xmx512m" clean install

About these ads

12 Comments »

  1. I get the same error message, minus the [INFO]. When I set the surefire.memory property, it doesn’t change anything. I haven’t changed any of my Maven configurations recently, and have been able to build my projects at least a day or 2 ago. Any ideas?

    Comment by Brad — February 10, 2010 @ 5:19 pm | Reply

    • When that has happened to me, I usually just keep increasing the amount of memory I am assigning the surefire.memory property until it works. A few times we have added tests, such as a concurrency test, that cause the memory needed to increase and had to up the amount of memory we were assigning the surefire.memory property.

      Comment by Brian — February 11, 2010 @ 5:17 pm | Reply

  2. Another thing: It says it can’t create the Java virtual machine, but if I run java or javac, I have no problem. I only run into this when using Maven.

    Comment by Brad — February 10, 2010 @ 5:26 pm | Reply

    • I have encountered that error before. It happens to me when I specify an amount of memory for the surefire.memory property that is greater than the amount of memory that is currently free on my machine. So when it tries to start, it tries to reserve that memory, it can’t do it and just throws an exception. Usually I close other apps on my machine, or try lowering the amount of memory I am assigning the surefire.memory property in increments until I find a number that works.

      Comment by Brian — February 11, 2010 @ 5:15 pm | Reply

  3. Thanks a lot for the reply. I found that my MVN_OPTS variable was set to use a gig of memory. It worked as soon as I cranked it down a bit. For whatever reason, I don’t have that much free memory anymore, but that’s something specific to my machine. Once again, thanks for pointing me in the right direction.

    Comment by Brad — February 12, 2010 @ 3:35 pm | Reply

    • This worked for me too. Thanks!

      Comment by Alfonso — August 11, 2010 @ 6:57 am | Reply

  4. I am glad I could help!

    Comment by Brian — February 13, 2010 @ 1:41 pm | Reply

  5. Thanks a lot. It worked for me too.

    Comment by Sumangala — September 10, 2011 @ 1:54 am | Reply

    • bonjour,j’ai besoin d’aggrandir l’espace mémoire de ma machine, j’ai essayé plusieurs valeur mais ça ne marche pas.y a t -il quelqu’un qui peut m’aider?
      merci

      Comment by souiud — October 11, 2011 @ 1:39 am | Reply

  6. I am facing the same issue but i increased my Maven_OPTS but tat did not help.

    Comment by buildit — January 23, 2012 @ 2:01 pm | Reply

  7. I had this same issue and I fixed it by adding %M2% in the “path” environment variable

    Comment by Fernando — April 26, 2012 @ 2:27 pm | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Rubric Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 29 other followers

%d bloggers like this: