3

Click here to load reader

Java - How to Tune Tomcat 5.5 JVM Memory Settings Without Using the Configuration Program - Stack Overflow

Embed Size (px)

Citation preview

Page 1: Java - How to Tune Tomcat 5.5 JVM Memory Settings Without Using the Configuration Program - Stack Overflow

redwards

56 1 1 5

8 Answers

Glenn

1,728 3 13

I need to configure Tomcat memory settings as part of a larger installation, so manually configuring tomcat

with the configuration app after the fact is out of the question. I thought I could just throw the JVM memory

settings into the JAVA_OPTS environment variable, but I'm testing that with jconsole to see if it works and

it... doesn't.

As per the comment below, CATALINA_OPTS doesn't work either. So far, the only way I can get it to work

is via the Tomcat configuration GUI, and that's not an acceptable solution for my problem.

java apache memory tomcat jvm

edited Nov 13 '08 at 5:40 asked Nov 13 '08 at 1:17

feedback

Serhii's suggestion works and here is some more detail.

If you look in your installation's bin directory you will see catalina.sh or .bat scripts. If you look in these you

will see that they run a setenv.sh or setenv.bat script respectively, if it exists, to set environment variables.

The relevant environment variables are described in the comments at the top of catalina.sh/bat. To use

them create, for example, a file $CATALINA_HOME/bin/setenv.sh with contents

export JAVA_OPTS="-server -Xmx512m"

For Windows you will need, in setenv.bat, something like

set JAVA_OPTS=-server -Xmx768m

Hope this helps, Glenn

answered Dec 3 '08 at 17:34

feedback

Create a setenv.(sh|bat) file in the tomcat/bin directory with the environment variables that you want

modified.

The catalina script checks if the setenv script exists and runs it to set the environment variables. This way

you can change the parameters to only one instance of tomcat and is easier to copy it to another

instance.

Probably your configuration app has created the setenv script and thats why tomcat is ignoring the

How to tune Tomcat 5.5 JVM Memory settings without using the configuration program

×Welcome to Q&A for professional and enthusiast programmers — check out the FAQ!

java - How to tune Tomcat 5.5 JVM Memory settings without using the con... http://stackoverflow.com/questions/286007/how-to-tune-tomcat-5-5-jvm...

1 of 3 9/30/2011 5:11 AM

Page 2: Java - How to Tune Tomcat 5.5 JVM Memory Settings Without Using the Configuration Program - Stack Overflow

Serhii

1,638 9 27

matt b

40.2k 9 62 130

Cozzman

86 3

Dmitriy Kochergin

21 1

FoxyBOA

1,834 11 23

answered Nov 28 '08 at 9:11

1 This solution, complemented with Glenn's solution, worked nice for me. – Elliot Vargas Mar 23 '10 at 15:04

feedback

Use the CATALINA_OPTS environment variable.

answered Nov 13 '08 at 1:20

I've tried CATALINA_OPTS, too. I'm pretty sure that only works for Tomcat 4.0 and earlier. – redwards Nov 13 '08

at 2:27

I can guarantee it works for 5.0.28. Check the startup.bat/sh and catalina.bat/sh to check what's being used.

Perhaps you are passing the arguments in the incorrect format? – matt b Nov 13 '08 at 2:50

feedback

Just to add to the previous comment, the documentation for the command line tool for updating the Tomcat

service settings (if Tomcat is running as a service on Windows) is here. This tool updates the registry with

the proper settings. So if you wanted to update the max memory setting for the Tomcat service you could

run this (from the tomcat/bin directory), assuming the default service name of Tomcat5:

tomcat5 //US//Tomcat5 --JvmMx=512

answered Nov 18 '08 at 18:00

feedback

I use following setenv.bat contents:

==============setenv.bat============

set JAVA_OPTS=-XX:MaxPermSize=256m -Xms256M -Xmx768M -Xdebug -Xnoagent

-Xrunjdwp:transport=dt_socket,address=7777,server=y,suspend=n %JAVA_OPTS%

====================================

It also enables debugging and sets debug port to 7777, and appends previous content of JAVA_OPTS.

answered Sep 6 '10 at 15:20

feedback

Not sure that it will be applicable solution for you. But the only way for monitoring tomcat memory settings

as well as number of connections etc. that actually works for us is Lambda Probe.

It shows most of informations that we need for Tomcat tunning. We tested it with Tomcat 5.5 and 6.0 and it

works fine despite beta status and date of last update in end of 2006.

answered Nov 13 '08 at 6:53

×Welcome to Q&A for professional and enthusiast programmers — check out the FAQ!

java - How to tune Tomcat 5.5 JVM Memory settings without using the con... http://stackoverflow.com/questions/286007/how-to-tune-tomcat-5-5-jvm...

2 of 3 9/30/2011 5:11 AM

Page 3: Java - How to Tune Tomcat 5.5 JVM Memory Settings Without Using the Configuration Program - Stack Overflow

kgiannakakis

41.2k 3 41 78

DrTune

11 2

feedback

If you'd start Tomcat manually (not as service), then the CATALINA_OPTS environment variable is the way

to go. If you'd start it as a service, then the settings are probably stored somewhere in the registry. I have

Tomcat 6 installed in my machine and I found the settings at the HKLM\SOFTWARE\Apache Software

Foundation\Procrun 2.0\Tomcat6\Parameters\Java key.

answered Nov 13 '08 at 7:15

feedback

Handy for linux virtual machines; Use 75% of your total system memory for Tomcat. Yay AWK.

Put at start of "{tomcat}/bin/startup.sh"

export CATALINA_OPTS="-Xmx`cat /proc/meminfo | grep MemTotal | awk '{ print $2*0.75 } '`k"

edited Oct 19 '10 at 0:55 answered Oct 19 '10 at 0:43

feedback

Not the answer you're looking for? Browse other questions tagged java apache

memory tomcat jvm or ask your own question.

question feed

×Welcome to Q&A for professional and enthusiast programmers — check out the FAQ!

java - How to tune Tomcat 5.5 JVM Memory settings without using the con... http://stackoverflow.com/questions/286007/how-to-tune-tomcat-5-5-jvm...

3 of 3 9/30/2011 5:11 AM