PDA

View Full Version : Memory allocation to JVM


dkumar2
25-03-2011, 19:28
Hi,

At one of the clients server, tomcat start script starts jvm like below.
It has two "-Xmx" argument, could you please clarify it to me what could be reason use it twice? Which one would be used by JVM?


/home/jdk/bin/java -Xmx1024m -Djava.util.logging.manager=org.apache.juli.ClassLo aderLogManager -Djava.util.logging.config.file=/home/tomcat/conf/logging.properties -server -Xmx1000m -Djava.awt.headless=true -Djava.endorsed.dirs=/home/tomcat/common/endorsed -classpath :/home/tomcat/bin/bootstrap.jar:/home/tomcat/bin/commons-logging-api.jar -Dcatalina.base=/home/tomcat -Dcatalina.home=/home/tomcat -Djava.io.tmpdir=/home/tomcat/temp org.apache.catalina.startup.Bootstrap start

kjkoster
25-03-2011, 20:23
Dear dkumar2,

That is obviously a mistake. You can only specify one heap size. I am not sure which one will be used. I would say that JVM will use whichever one you decide to keep. :-)

Kees Jan

dkumar2
25-03-2011, 20:37
Dear Kees,

The later Xmx has been appended as CATALINA_OPTS="-server -Xmx1000m -Djava.awt.headless=true"

I am just trying to make out which one would be used by jvm? what would be its impact?

kjkoster
25-03-2011, 20:43
Dear dkumar2,

I don't know which one would be used. You can test this by setting one to (say) 1GB and the other to (say) 512MB. Then look in Java-monitor.com to see what value is actually used.

I don't expect setting this twice to do any harm. It is just confusing to the admins, that's all.

Kees Jan

dkumar2
25-03-2011, 22:38
Dear Kees,

I got it.

The first Xmx is declared as JAVA_OPTS and the later one is as CATALINA_OPTS.
Let me know about your comments. Thanks.

kjkoster
26-03-2011, 06:44
Dear dkumar2,

I would say to define -Xmx in JAVA_OPTS, since it is for the JVM. I'd use CATALINA_OPTS for Tomcat-specific options.


But it's your machine. :)

Kees Jan