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 setenv.sh file and u put in it :
JAVA_HOME="/usr/local/java"
export JAVA_HOME
JAVA_OPTS="-Xmx256m -Xms256m"
export JAVA_OPTS
CATALINA_HOME="/usr/local/tomcat"
export CATALINA_HOME
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/logging.properties -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 -Djava.io.tmpdir=/usr/local/tomcat/temp 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.
Best Answer
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:
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.