View Full Version : Tomcat and JVM memory usage
doktoreas
27-08-2009, 13:50
Hello folks,
I have a question about memory usage and JVM/Tomcat:
This is the script I created to start tomcat:
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export JAVA_OPTS="-Djava.awt.headless=true -server -Xms48m -Xmx1024M -XX:MaxPermSize=512m -XX:+UseParallelGC"
case $1 in
start)
sh /usr/local/tomcat/bin/startup.sh
;;
stop)
sh /usr/local/tomcat/bin/shutdown.sh
;;
restart)
sh /usr/local/tomcat/bin/shutdown.sh
sh /usr/local/tomcat/bin/startup.sh
;;
esac
exit 0
After some days top shows that java is using 53% ( 2 Gb); why this value?
More info:
VIRT 3491m
RES 2.1g
SHR 15m
%MEM 53.5
Using the xmx option doesn't block the max to 1024?
My OSis Ubuntu LTS Server edition.
Thank you
Luca
kjkoster
27-08-2009, 13:58
Dear Luca,
Well, you have given Java about 1.5GB (1GB Heap plus .5 GB non-heap). I expect there to be some overhead and some rounding errors.
What you can do is check that the arguments are passed to the JVM properly and not overridden anywhere. You can do that by running ps and seeing the full command line (you should see the -D... on that command line).
Otherwise, hook up jconsole or Java-monitor to see what the size of the individual memory pools in Java is.
And yes, specifying -Xmx1G should keep Java from going up much higher (though there will be overhead).
Kees Jan
doktoreas
27-08-2009, 14:06
Dear Luca,
Well, you have given Java about 1.5GB (1GB Heap plus .5 GB non-heap). I expect there to be some overhead and some rounding errors.
What you can do is check that the arguments are passed to the JVM properly and not overridden anywhere. You can do that by running ps and seeing the full command line (you should see the -D... on that command line).
Otherwise, hook up jconsole or Java-monitor to see what the size of the individual memory pools in Java is.
And yes, specifying -Xmx1G should keep Java from going up much higher (though there will be overhead).
Kees Jan
Hi Jan and thanks for your answer..this is the output from ps:
ps -A -f |grep java
root 14746 1 0 Aug21 ? 00:05:12 /usr/lib/jvm/java-6-sun/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.awt.headless=true -server -Xms48m -Xmx1024m -XX:MaxPermSize=512m -XX:+UseParallelGC -Djava.util.logging.manager=org.apache.juli.ClassLo aderLogManager -Djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath :/usr/local/tomcat/bin/bootstrap.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
1000 16503 16477 0 15:03 pts/0 00:00:00 grep java
It seems fine..don't you think?
Thx
Luca
kjkoster
27-08-2009, 14:08
Dear Luca,
I agree, that looks fine. What does jconsole or Java-monitor say about the pool sizes?
Kees Jan
doktoreas
27-08-2009, 14:11
Dear Luca,
I agree, that looks fine. What does jconsole or Java-monitor say about the pool sizes?
Kees Jan
Sorry for my ignorance, but where can I check it using Java Monitor?
thx
Luca
kjkoster
27-08-2009, 14:42
Dear Luca,
Check out http://java-monitor.com/install.html
Once Java-monitor is installed, you can go to the host's page from the forum (just click on the host) and then see.
Kees Jan
doktoreas
27-08-2009, 18:42
Dear Luca,
Check out http://java-monitor.com/install.html
Once Java-monitor is installed, you can go to the host's page from the forum (just click on the host) and then see.
Kees Jan
Hi Jan,
it's already installed...which graph should I check to understand the problem?
Thanks
Luca
kjkoster
28-08-2009, 19:17
Dear Luca,
Have a look at the graphs displaying the heap and nonheap memory pools. They are the top two graphs of a host.
You can post them (in a new thread) in the forum if you have questions about them. There is a button just under each graph.
Kees Jan
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.