Reputation: 4328
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
Upvotes: 1
Views: 9836
Reputation: 6354
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.
Upvotes: 0
Reputation: 79
Set again with below and try:
Linux:
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=1024m"
Windows
set MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=1024m"
Upvotes: 3