Skip to main content

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


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.


Source: Tips4allCCNA FINAL EXAM

Comments

  1. 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 environment variables.

    ReplyDelete
  2. Use the CATALINA_OPTS environment variable.

    ReplyDelete
  3. If you using Ubuntu 11.10 and apache-tomcat6 (installing from apt-get), you can put this configuration at /usr/share/tomcat6/bin/catalina.sh

    # -----------------------------------------------------------------------------

    JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1024m \
    -Xmx1024m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:PermSize=512m \
    -XX:MaxPermSize=512m -XX:+DisableExplicitGC"


    After that, you can check your configuration via ps -ef | grep tomcat :)

    ReplyDelete
  4. 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

    ReplyDelete
  5. 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.

    ReplyDelete
  6. 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"

    ReplyDelete
  7. 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.

    ReplyDelete
  8. 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.

    ReplyDelete
  9. I like the idea of seting tomcat6 memory based on available server memory (it is cool because I don't have to change the setup after hardware upgrade). Here is my (a bit extended memory setup):


    export CATALINA_OPTS="-Xmxcat /proc/meminfo | grep MemTotal | awk '{
    print $2*0.75 } 'k -Xmscat /proc/meminfo | grep MemTotal | awk '{
    print $2*0.75 } 'k -XX:NewSize=cat /proc/meminfo | grep MemTotal |
    awk '{ print $2*0.15 } 'k -XX:MaxNewSize=cat /proc/meminfo | grep
    MemTotal | awk '{ print $2*0.15 } 'k -XX:PermSize=cat /proc/meminfo
    | grep MemTotal | awk '{ print $2*0.15 } 'k -XX:MaxPermSize=cat
    /proc/meminfo | grep MemTotal | awk '{ print $2*0.15 } 'k"


    Put it to: "{tomcat}/bin/startup.sh" (e.g. "/usr/share/tomcat6/bin" for Ubuntu 10.10)

    ReplyDelete

Post a Comment

Popular posts from this blog

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex