How to Tune Tomcat 5.5 Jvm Memory Settings Without Using the Configuration Program

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

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

Appropriate Tomcat 5.5 start-up parameters to tune JVM for extremely high demand, large heap web application?

One of the Java Champions, Kirk Pepperdine's blog : http://kirk.blog-city.com/how_to_cripple_gc_ergonomics.htm.

Quote 1
"GC documentation will tell you what the setting affects but often without telling what the effect will be. The biggest clue that you've taken the wrong fork in the road is when you explicitly set a value and then give a hint to GC ergonomics. Another clue is if you don't have a sound reason to adjust a setting. And just because some so called expert says this setting works best is only noise, not sound and certanly not a reason."

Quote 2
"As I've stated in a prevous blog entry , don't touch the knobs unless you have a very good reason to do so. If you must touch the knobs, tred lightly by only using those that help ergonomics and not those that pin things down crippling ergonomics ability to meet your pause time and throughput goals."

So, I would suggest that you go back to plain

-server -Xms1280m -Xmx1280m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:-TraceClassUnloading -Dsun.io.useCanonCaches=false -Dsun.net.client.defaultConnectTimeout=60000 -Dsun.net.client.defaultReadTimeout=60000

Find if that gives you better performance. If yes, stick to it

BTW, did -XX:MaxPermSize=378m have any issues ?

Java 1.6 has much better ergonomics than 1.4. You might want to tune it less than 1.4

BTW, did you try Tomcat 6 ? Tomcat 6 runs much better on Java 6 than Tomcat 5.5.

P.S : I've been using Tomcat for a while now and usually try to give sun's JDK free reign with little tuning here and there.

Where can I permanently set java heap size on Windows pc?

You can use the JAVA_OPTS environment variable for dealing with java heap size.
This variable can be added as a environment variable as well as you can define a configuration line in the startup.bat file.

Add the following line in the startup.bat file.

set JAVA_OPTS=-Xms512m -Xmx512m

You can add this as environment variable as said.

Difference between setting Heap memory in terms of jvm and Tomcat

Memory settings apply to the JVM, not Tomcat

You can create a separate file %CATALINA_HOME%\bin\setenv.bat or $CATALINA_HOME/bin/setenv.sh and put your environment variables there.

so I'd like to set the JAVA_OPTS variable instead:

set JAVA_OPTS=-Xmx512m

For Xmx:

Specifies the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. The upper limit for this value will be approximately 4000m on Solaris 7 and Solaris 8 SPARC platforms and 2000m on Solaris 2.6 and x86 platforms, minus overhead amounts. So, in simple words, you are saying Java to use Maximum of 1024 MB from available memory.

NOTE: there is NO SPACE between -Xmx and 1024m

Resource Link:

  1. How to Change JVM Heap Setting (-Xms -Xmx) of Tomcat – Configure
    setenv.sh file – Run catalina.sh
  2. How to Increase Apache Tomcat HeapSize (JVM Heap) in Eclipse IDE
    (integrated development environment) to Avoid OutOfMemory

UPDATE1: Setting Up Multiple Tomcat Instances

Multiple Tomcat instances are possible to create with the use of the CATALINA_BASE environment variable. Each instance uses a common binary distribution but uses its own conf, webapps, temp, logs and work directories. Each instance also has its own JVM and, thereby, its own memory pool. If you have defined the maximum memory to be 512MB via JAVA_OPTS, each instance will attempt to allocate a maximum of 512MB.

For more details, you can go through this tutorial: Connecting Apache's Web Server to Multiple Instances of Tomcat

Resource Link:

  1. 5 Scenarios and Best Practices for Running Multiple Instances of
    Tomcat or tc Server

How can I allocate more than 1 gb memory to tomcat on x64 windows7

Now i have
JAVA_OPTS="-server -XX:MaxPermSize=512M -Xms2048M -Xmx2048M -Xss64M -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled" in catalina.bat (suggested by chrome). It seems that all works fine.
In the prev conf i had only -Xms2048M -Xmx2048M options.

Than you guys for the help!



Related Topics



Leave a reply



Submit