Solved

Tomcat Memory Allocations

Posted on 2015-01-05
5
322 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 62

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 27

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 27

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 62

Expert Comment

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.
Suggested Courses

710 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