Thomas Sundberg

October 14, 2011

Maven Java heap space

This post has been migrated to

I just had test in a Maven build fail with

java.lang.OutOfMemoryError: Java heap space

It turns out that when Maven fork a new process to run the tests in, it doesn’t seem to honor your MAVEN_OPTS settings and pass them to the new process. The solution may be to set the heap size for the Surefire, and possible Failsafe, plugin. This can be done with the optional argLine parameter.


This solved my urgent problem, getting the build to pass. My long term problem is now to understand why the test need more memory then before.



  1. Did you ever find a long-term solution to this problem?

    Comment by Evan B — October 11, 2013 @ 19:05

  2. No, I never did solve that problem.

    Comment by Thomas Sundberg — October 11, 2013 @ 21:32

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

You are commenting using your 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

Blog at

%d bloggers like this: