How to increase Java heap space for a tomcat app

前端 未结 10 2364
攒了一身酷
攒了一身酷 2020-12-08 09:59

There are lots of questions that ask this or a similar question.

They all give the command that has to be executed, what I don\'t understand is where do I write this

相关标签:
10条回答
  • 2020-12-08 10:43

    Just set this extra line in catalina.bat file

    LINE NO AROUND: 143

    set "CATALINA_OPTS=-Xms512m -Xmx512m"
    

    And restart Tomcat service

    0 讨论(0)
  • 2020-12-08 10:47

    There is a mechanism to do it without modifying any files that are in the distribution. You can create a separate file %CATALINA_HOME%\bin\setenv.bat or $CATALINA_HOME/bin/setenv.sh and put your environment variables there. Further, the memory settings apply to the JVM, not Tomcat, so I'd set the JAVA_OPTS variable instead:

    set JAVA_OPTS=-Xmx512m

    0 讨论(0)
  • 2020-12-08 10:48
    • Open the server tab in eclipse
    • right click open
    • click on open lauch configuration
    • Go to arguments
    • Here you can add in VM arguments after endorsed

      -Xms64m -Xmx256m
      
    0 讨论(0)
  • 2020-12-08 10:49

    First of all you cannot change the memory settings only for a tomcat application but rather for all tomcat instance.

    If you are running tomcat from console (using startup.bat) you'll need to edit catalina.bat and play around with CATALINA_OPTS. For example:

    set CATALINA_OPTS=-Xms512m -Xmx512m
    

    Restarting tomcat will apply the new settings.

    If you are still getting OutOfMemoryError you need to know how much memory does your application need at that particular moment (nom.tam.util.ArrayFuncs...). You'll either have to optimize the application or simply increase the memory provided to tomcat.

    0 讨论(0)
  • 2020-12-08 10:49

    you can set this in catalina.sh as CATALINA_OPTS=-Xms512m -Xmx512m

    Open your tomcat-dir/bin/catalina.sh file and add following line anywhere -

    CATALINA_OPTS="$CATALINA_OPTS -Xms1024m -Xmx3024m"
    

    and restart your tomcat

    0 讨论(0)
  • 2020-12-08 10:50

    You need to add the following lines in your catalina.sh file.

    export CATALINA_OPTS="-Xms512M -Xmx1024M"
    

    UPDATE : catalina.sh content clearly says -

    Do not set the variables in this script. Instead put them into a script setenv.sh in CATALINA_BASE/bin to keep your customizations separate.

    So you can add above in setenv.sh instead (create a file if it does not exist).

    0 讨论(0)
提交回复
热议问题