MAVEN_OPTS : How to increase JVM memory
In this post, we will see how to increase JVM memory using the environment variable MAVEN_OPTS. MAVEN_OPTS is the Java runtime options used when Maven is run. Sometimes, while running a large number of JBehave stories we might get OutOfMemoryError at runtime.
For example, we might get something like this:
Caused by: java.lang.OutOfMemoryError: PermGen space
What is MAVEN_OPTS?
MAVEN_OPTS is an environment variable. It defines options for the JVM that executes Maven. We can set/increase JVM memory with this variable. We can set it according to our operating system.
For example, on *nix system we can use
On Windows, we can use
If you are getting an OutOfMemoryException when running maven, we can try increasing the JVM memory to resolve this error.
This will allocate 512MB of RAM to Maven.
On Windows Operating system
We can set or increase memory in many ways.
For example: using the windows command prompt
/> set MAVEN_OPTS=”-Xmx512M -XX:MaxPermSize=512m”
We may also set the variable in Environment variables in
Control Panel >> System >> Advanced >> Environment Variables…
To enter new variable click on ‘New’ under user variables, then enter MAVEN_OPTS as the variable name and the value
If you already have set the environment variable, edit it to increase the memory. Also, note that the value 512M is chosen for example sake. The most suitable value depends and varies with the environment.
JBehave Tutorials on this website can be found at:
For more details on the JBehave framework, visit the official JBehave website at: