1

How is this possible? I do not understand linux correctly because I do not know how this can happen. I believe there is something else happening here as im trying to set the max heap size to 1G and it is failing

The MAVEN_OPTS specify a heap of 1024m but the maven command fails because the heap is 4096m. The machine is 32 bit with 6G installed

Memory

$free -h
             total       used       free     shared    buffers     cached
Mem:          5.8G       3.8G       2.0G       186M       351M       2.1G
-/+ buffers/cache:       1.3G       4.4G
Swap:         5.8G         0B       5.8G

Maven

echo $MAVEN_OPTS
-Xms512m -Xmx1024m -XX:MaxPermSize=1024m

$ mvn -version
Invalid maximum heap size: -Xmx4096m
The specified size exceeds the maximum representable size.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Java

java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) Server VM (build 25.111-b14, mixed mode)

Linux

uname -a 102-Ubuntu SMP Tue Aug 11 14:28:35 UTC 2015 i686 i686 i686 GNU/Linux
Dave
  • 4,184
  • 8
  • 40
  • 46
  • 1
    Possible duplicate of [Increasing the JVM maximum heap size for memory intensive applications](http://stackoverflow.com/questions/3030263/increasing-the-jvm-maximum-heap-size-for-memory-intensive-applications) – rec Jan 04 '17 at 18:42
  • thanks i looked at that before. I believe there is something else happening here as im trying to set themax heap size to 1G and it is failing – Dave Jan 04 '17 at 18:46
  • what is the output of `which mvn`? Is it a shell script? What are its contents? – Omaha Jan 04 '17 at 19:16
  • What's the Maven command? How does it crash (what error do you see)? – Stanislav Bashkyrtsev Jan 04 '17 at 19:40

2 Answers2

2

Set again with below and try:

Linux:

export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=1024m"

Windows

set MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=1024m"

Anton Dozortsev
  • 4,782
  • 5
  • 34
  • 69
rsh
  • 69
  • 4
  • same result. It seems the value for heap size is being set somewhere else but I cant think of a place which takes prescience over the bash session cli. – Dave Jan 04 '17 at 18:49
  • 1
    check in configuration file - ${user.home}/.m2/settings.xml – rsh Jan 04 '17 at 18:58
  • 1
    Ever checked JAVA_OPTS ? – khmarbaise Jan 04 '17 at 19:48
  • 1
    check system environment variable MAVEN_OPTS values – rsh Jan 04 '17 at 20:43
  • Yeah I checked JAVA_OPTS, echo $JAVA_OPTS showed me it is unset. – Dave Jan 04 '17 at 21:37
  • 1
    Hi, the Windows command is incorrect. It should be `set MAVEN_OPTS=-Xmx1024m -XX:MaxPermSize=1024m`. Also, `MaxPermSIze` is ignored in Java 8+. The new setting is `-XX:maxMetaspace=1024m`. – steve May 18 '20 at 11:00
0

I just ran across this same error, and the solution was provided to my via this blog post. In the post, it is stated;

Check mvn.bat: the MAVEN_OPTS is passed as JVM parameter directly:

SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" %MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%

If we run set MAVEN_OPTS="-Xmx1024M -XX:MaxPermSize=256M",the previous command would be replaced with %MAVEN_JAVA_EXE% "-Xmx1024M -XX:MaxPermSize=256M" ...

If we run java "-Xmx1024M -XX:MaxermSize=256M" -version: we will see same error message.

The solution is simple: We can run: set "MAVEN_OPTS=-Xmx1024M -XX:MaxPermSize=256M" or remove the double quotes completely: set MAVEN_OPTS=-Xmx1024M -XX:MaxPermSize=256M

The value of MAVEN_OPTS would be with no surrounding double quotes.

This certainly addressed my issue.

Mr Moose
  • 5,946
  • 7
  • 34
  • 69