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.

About these ads
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 ?

    • mcguy says:

      Look in the bin directory inside tomcat directory.
      If I can suggest you something, next time do a research with find (linux) or CTRL F (windows).
      Nice day :)

    • vjay says:

      yes u r rite same prblm wth me also…..

    • TimmiReddy says:

      Hi All,
      To set the
      CATALINA_OPTS=”-Xms1024m -Xmx1024m”

      The above property in startup.bat file while is available in tomcat\bin directory path.

    • Sekhar says:

      Hi All,
      To set the below comment in startup.bat file as

      set CATALINA_OPTS=”-Xms1024m -Xmx1024m”

      startup.bat file is available in tomcat\bin directory path.

  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%

    • Samuel says:

      Hi mingliangfeng, In my tomcat directory I don’t have the catalina.sh or catalina.bat file, however I can create the file setenv.bat, the question is: where do I invoque this file in the startup process?

  14. Jual Jaket Kulit Murah says:

    Hi Abid,

    Thanks for sharing your HOW-TO.

  15. steve Button says:

    more of a tweet than a full blog entry, and the comments are 10x the size of the “post”. :-P

    I was actually searching to find out why tomcat 6 seems to leak so much memory and crash our servers.

  16. guhan says:

    Even i tried increasing the size It aint worked out . Then what is the other procedure to follow ? can anyone help out with this java heap space issue. thanks in advance.

  17. manish says:

    Hmmm i too need the alternative

    • ramya says:

      Ramya says:

      to increase the heap memory size in tomact: tomact6.0->bin->startup.bat(rightclick->edit) and set like “set JAVA_OPTS=-Xmx512m -XX:MaxPermSize=256m”
      try this.

  18. honey says:

    to increase heap size for tomcat
    For windows os :MyComputer->properties->Advanced->environment variables->System variables->New->Variable name:CATALINA_OPTS->Variable value:-Xms64m -Xmx256m

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