1
votes

I have set the Xmx parameter for JVM to 5120 but when the java process(tomcat) runs, I see that the MaxHeapSize does not match the Xmx value, it is stuck at 2570, which is strange to me, any thoughts on this are much appreciated!!

Output of ps:

/usr/bin/java -Dnop -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms1536m -Xmx5120 -Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=true -Djava.net.preferIPv4Stack=true -DSHUTDOWN_PORT=8005 -DHTTP_PORT=8080 -DHTTPS_PORT=8443 -DAJP_PORT=8009 -XX:InitialHeapSize=2570m -XX:MaxHeapSize=2570m -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m -XX:+DisableExplicitGC -Djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/app/tomcat/default -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/app/tomcat/default/temp org.apache.catalina.

2
-Xmx5120 should be Xmx5120muser3778137

2 Answers

3
votes

The -Xmx option is equivalent to -XX:MaxHeapSize.

(https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html)

So -Xmx5120 means 5120 Bytes but is superseeded by -XX:MaxHeapSize=2570m. That is the reason you are stuck by this.

Just provide only one of these settings and choose the proper value, e.g.

-Xmx5120m
2
votes

Problems in your config:

-Xms1536m -Xmx5120

If you don't specify the unit of this config, it will be parsed as bytes, which means your Xmx is less than your Xms, if this config applies JVM will failed to launch:

 ~/ java -Xms1536m -Xmx5120 -XX:+PrintFlagsFinal -version
Error occurred during initialization of VM
Initial heap size set to a larger value than the maximum heap size

Your JVM did not aborted because you have following configs:

-XX:InitialHeapSize=2570m -XX:MaxHeapSize=2570m

-Xms is -XX:InitialHeapSize and -Xmx is -XX:MaxHeapSize, so your previous wrong config of -Xms1536m -Xmx5120 is replaced by the later ones, which specified Xmx to be 2570M.