Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I bought a virtual server with 1gb of memory to run java web site application. I have installed Tomcat 6.0.33 . Each time i run tomcat, it s taking around 450 mb of memory.

I tried everything to reduce that, i set up the CATALINA_OPS as

export CATALINA_OPTS="-Xms256m -Xmx256m"

I have created set file and u put in it :

export JAVA_HOME

JAVA_OPTS="-Xmx256m -Xms256m"
export JAVA_OPTS


When i pass this command : ps -ef | grep tomcat i have :

root      3150     1  5 15:32 pts/0    00:00:18 /usr/local/java/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/ -Xmx256m -Xms256m -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms256m -Xmx256m -Djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath /usr/local/tomcat/bin/bootstrap.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat org.apache.catalina.startup.Bootstrap start
root      3217  2041  0 15:37 pts/0    00:00:00 grep tomcat

which shows me that my parameters are really used.

Is there any method to reduce the memory consumed by tomcat ? Thank you.

share|improve this question

migrated from Sep 19 '11 at 5:02

This question came from our site for professional and enthusiast programmers.

The issue here isn't really tomcat, it's java generally. There are a number of different places where java uses memory. The java runtime uses it's own memory and that's going to be included in your number, additionally, java breaks memory down into four distinct locations:

The Heap: This is the memory used to store your objects and is controlled by the -Xms and -Xmx parameters.

The Stack: This is the memory used to store the stack frames for the threads that your program maintains and can be controlled with the -Xss parameter.

Permgen Memory: This is the memory used to store your compiled classes and pooled strings as well as some other things and can usually be controlled with -XX:MaxPermSize although the -XX represents a debugging parameter, so there's no guarantee it's on all JVM's. But, the default Sun/Oracle reference implementations have always had them.

JNI Allocated Memory Any classes utilizing native methods and JNI could potentially allocate unlimited memory. This memory comes from the OS and not the heap and there's no way of knowing how much memory a native class will use without having access to the source.

An overview of the java memory model is probably beyond the scope of the answer to this question and I couldn't find a good concise article/description on the internet, but the short answer to your question is if you are trying to limit the absolute amount of memory used by a java program, there is no easy way to do it. Heuristically, probably cut your -Xms and -Xmx parameters to 128m and you should get close, but it's really going to depend on your application.

share|improve this answer
Thank you for your answer, i realized that it's still consuming that memory even if havo zero application deployed. Reaaly weird. – stunaz Sep 18 '11 at 21:51
Yeah. Tomcat is a java application and it will use memory even if you don't have any other web applications. Addtionally, if you are using JNI for anything that could also consume memory. I edited the answer to reflect that. – dlawrence Sep 18 '11 at 21:59
"How to reduce Tomcat's memory usage?" -> Do not use Tomcat. – robert Sep 19 '11 at 12:20
hi, robert, what do you suggest? – stunaz Sep 19 '11 at 13:26

Run pmap <PID> to find out how the memory is allocated. This is generic for any binary. For java you have jmap <PID>. To see the startup parameters of the JVM use jinfo -XX:+PrintCommandLineFlags <PID>.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.