Configure heap size for Tomcat 6.x

Posted: April 4, 2008 in howto
Tags: ,

After looking around a bit, here is how I learned to configure heap size for Tomcat 6.x:

export CATALINA_OPTS="-Xms1024m -Xmx1024m" 

Thanks to this post for the information.

Comments
  1. ron ihmoff says:

    does this work on a win2003 box with tomcat starting as a service ?

  2. abid says:

    How to set java heap size in Tomcat?
    Stop Tomcat server, set environment variable CATALINA_OPTS, and then restart Tomcat. Look at the file tomcat-install/bin/catalina.sh or catalina.bat for how this variable is used. For example,

    set CATALINA_OPTS=”-Xms512m -Xmx512m” (Windows)
    export CATALINA_OPTS=”-Xms512m -Xmx512m” (ksh/bash)
    setenv CATALINA_OPTS “-Xms512m -Xmx512m” (tcsh/csh)

    In catalina.bat or catallina.sh, you may have noticed CATALINA_OPTS, JAVA_OPTS, or both can be used to specify Tomcat JVM options. What is the difference between CATALINA_OPTS and JAVA_OPTS? The name CATALINA_OPTS is specific for Tomcat servlet container, whereas JAVA_OPTS may be used by other java applications (e.g., JBoss). Since environment variables are shared by all applications, we don’t want Tomcat to inadvertently pick up the JVM options intended for other apps. I prefer to use CATALINA_OPTS.

    Abid,
    http://www.abidshafiq.com

    • gaius says:

      Yes, but doesn’t JAVA_OPTS override CATALINA_OPTS?

    • Mekerira says:

      Hi Abid / Dave,

      I’m very new to this setting JAVA_OPTS variable.
      Please can you explain in detail.

      Stepwise proc for configuring
      for linux machines as well(not much aware about the linux commands aswell)

      –one more question :
      1) If i have two tomcat application running on my windows XP ,does this JAVA_OPTS
      size apply for both, if yes how to make it specific for each application.

      2)what does Xms and DXms stand for.

      Thanks in advance

  3. Dave says:

    Hi Abid,

    Thanks for sharing your HOW-TO.

  4. fatih says:

    To set the
    CATALINA_OPTS=”-Xms1024m -Xmx1024m”
    property in the catalina.sh or catalina.bat file, i should find these files firstly :) These files do not exist in my Tomcat 6 directory:
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\

    How will I configure the heap size ?

  5. jaypee says:

    hi,
    I want to configure the heap size in tomcat 6.0.

    In my tomcat directory i dont have the catalina.sh or catalina.bat file.
    How can i configure in this situation.

    Thanks in Advance…

    Jaypee………..

  6. srinivas says:

    Hi All,

    1. I Recorded the Script for Company creation and User creation. When executing the Script it is displaying error message like “java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(Unknown Source)”

    How we can solve this Problem

    2. Can u send me the process how to Insert the Data in DB by using JMeter.

    3. In JMeter how many Vusers we can create

    Regards,
    srinivas

  7. Kamran Omar says:

    Hi,
    I am using Window-XP. i make changes both in catalina.sh or catalina.bat but i think tomcat 6.0.14 not using those file.

    Kindly tell me how i increase my tomcat heap memory.

    Thanks.

    Best Regards,
    Kamran Omar

  8. rajesh says:

    Hi,

    You can set in starttomcat as mentioned in http://hiox.org/index.php?id=443

    Regards,
    Rajesh

  9. santosh says:

    Thanks you so much ..i really spent a lot time on this but at many places it was not mentioned how exactly n where to place these arguments…cheers :)

  10. Alex says:

    what about how to solve java heap space errror in my tomcat i am using Ubuntu OS and everytime when i try to load a module in tomcat it’s shows the java heap space, need some help please

  11. pranav says:

    Thanks for it, I was looking for it quite a while.

  12. Web Hosting says:

    Does anyone know what would be the minimum java heap size for Tomcat? Will tomcat run for example with only 48MB?

  13. For Windows, create a new file setenv.bat and put the following into the file:
    set JAVA_OPTS=-XX:MaxPermSize=512m -Xms512M -Xmx1024M %JAVA_OPTS%

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s