Solved

Tomcat Memory Allocations

Posted on 2015-01-05
5
247 Views
Last Modified: 2015-01-06
I have a website running on Tomcat and I am trying to understand the memory allocation settings specifically the Java flags  -Xms & -Xms and the Tomcat --JvmMs, JvmMx memory pool allocations.

Now I have read through numerous sites including Oracle and Tomcat specifications and underrstand that these flags are used to set minimum and maximum memory poo sizes and that this relates to Garbage Collection but what this escapes me is what is the difference between these two groups of settings.

I have found with testing that setting --JvmMs & JvmMx to something really low (10m) causes Tomcat to crash during start up (no errors logged) and that setting -Xms & -Xms to 10m allows Tomcat to start but causes the site to timeout. Given this I suspect that these two sets memory allocation are controlling different aspects of the website.

Can anyone out there explain the what each of these two groups control in relation to each other.

I also find it strange that when running Tomcat in exe mode that --JvmMs and JvmMx are not used, so why are they needed for running as a service?
0
Comment
Question by:Michael74
  • 2
  • 2
5 Comments
 
LVL 61

Expert Comment

by:gheist
ID: 40533304
Good start is to not tune anything and analyze OOMs - do you need more memory or you need to address resource leak.
0
 
LVL 26

Accepted Solution

by:
dpearson earned 500 total points
ID: 40534211
I think you'll find there's actually only 2 values in use here.

-Xms defines the initial Java heap size to use
-Xmx defines the maximum heap size it is allowed to use

These flags are generic to all Java programs, nothing specific about Tomcat and a Java process only ever has one heap with a specific maximum size.  These are set on the JVM (the Java Virtual Machine - the thing which runs Java apps) when it starts up.

These 2 other flags ( JvmMs & JvmMx) sound like a Tomcat specific way to go about configuring the real flags for the JVM.  You can see it in their names - they are intended to be passed to the JVM and set the Ms and Mx flags.

So I'd guess that the reason you're seeing setting some of these producing different behavior is that there's some level of overriding going on and sometimes the flags are set and clobbered by other values and sometimes not.

To see what's really going on, I'd suggest using "ps aux | grep java" to look at the running process and the command line actually used to launch it.

You should see something similar to this:

/usr/bin/java -Djava.util.logging.config.file=/var/local/tomcat/ow/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xmx3500M -Dcom.sun.management.jmxremote=true -XX:PermSize=256m -XX:MaxPermSize=512m -Djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/var/local/tomcat/ow -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/var/local/tomcat/ow/temp org.apache.catalina.startup.Bootstrap start

which contains the actual params used - you can see here we have ours set to 3.5GB as max heap.

It should help you sort out what's happening.

Doug
0
 
LVL 23

Author Comment

by:Michael74
ID: 40534411
Hi Doug

Thank you, good answer.

Any chance you know the command I could use to get this information on Win2k8
0
 
LVL 26

Expert Comment

by:dpearson
ID: 40534523
I think you can see the command line params for a running Windows process by going to:

1) Task manager
2) Switch to process tab
3) Select "View | Select columns" from the menu
4) Choosing "Command line" in the list of options

Then just hunt for Tomcat by hand in the list of tasks :)

I trust that option is available in Win2K8.  I just checked and it worked for me on Windows 7.

Doug
0
 
LVL 61

Expert Comment

by:gheist
ID: 40534530
look into catalina.out file for OOM, and change parameters with tomcat service controller.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now