I am running Tomcat on a small VPS (256MB/512MB) and I want to explicitly limit the amount of memory Tomcat uses.
I understand that I can configure this somehow by passing in the java maximum heap and initial heap size arguments;
-Xmx256m -Xms128m
But I can't find where to put this in the configuration of Tomcat 6 on Ubuntu.
Thanks in advance,
Gav
In general, a minimal install requires 4GB for the OS, the tomcat heap XMS setting (default 4GB), 2GB for Retain and any memory the database requires if installed. In all cases, when only the worker is installed the memory is automatically tuned to 3GB.
(X denotes the Tomcat version number) Click the Java tab. Enter the following recommended values: Initial memory pool — 1024 MB. Maximum memory pool — 1024 MB.
Heap size used by tomcat (as any other java app) is determined by jvm -Xmx param. So if your tomcat runs as a windows service, you would create environment variable CATALINA_OPTS=-Xms64m -Xmx256m. Then, look at the file tomcat-install/bin/catalina.sh (.
-xmx and -xms are the parameters used to adjust the heap size. -Xms: It is used for setting the initial and minimum heap size. It is recommended to set the minimum heap size equivalent to the maximum heap size in order to minimize the garbage collection. -Xmx: It is used for setting the maximum heap size.
On Ubuntu, the correct way to customize Tomcat variables is by editing the file
/etc/default/tomcat5.5
(or /etc/default/tomcat6
if you have a newer version running)
Inside that file, set the JAVA_OPTS variable as described in the other replies here, for example
JAVA_OPTS="-Xmx512m"
to set a maximum memory of 512 MB.
Set JAVA_OPTS in your init script,
export JAVA_OPTS="-Djava.awt.headless=true -server -Xms48m -Xmx1024M -XX:MaxPermSize=512m"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With