Best way to increase heap size in catalina.bat file
Asked Answered
G

2

10

I have tomcat 6 server on windows xp ,And I start tomcat through console i.e. using startup.bat.

AFAIK catalina.bat file is for windows so I am changing bat file for memory management.I don't have tomcat configuration window.

Now I want to increase its heap size so My question is should I extend the existing JAVA_OPTS in catalina.bat file i.e.

set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties" -Xms1024m -Xmx1024m -XX:PermSize=256m  -XX:MaxPermSize=128m  

Or should I create new environment variable in catalina.bat file i.e.

set JAVA_OPTS=-Xms1024m -Xmx1024m -XX:PermSize=256m  -XX:MaxPermSize=128m 

And Is this the correct way to do it?

Please guide.

and I am able to see current heap size in Probe but not able to see existing perm size so What is the default value for perm size?

Edit:

following parameters help any?

-XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled
Griffis answered 23/9, 2012 at 14:53 Comment(0)
R
25

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

Original answer here

After you run startup.bat, you can easily confirm the correct settings have been applied provided you have turned @echo on somewhere in your catatlina.bat file (a good place could be immediately after echo Using CLASSPATH: "%CLASSPATH%"):

enter image description here

Roseroseann answered 23/9, 2012 at 16:9 Comment(1)
Note from the Tomcat docs (tomcat.apache.org/tomcat-7.0-doc/RUNNING.txt): "Note: Do not use JAVA_OPTS to specify memory limits. You do not need much memory for a small process that is used to stop Tomcat. Those settings belong to CATALINA_OPTS."Plowboy
R
7

increase heap size of tomcat for window add this file in apache-tomcat-7.0.42\bin

enter image description here

heap size can be changed based on Requirements.

  set JAVA_OPTS=-Dfile.encoding=UTF-8 -Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256m
Rafi answered 6/4, 2015 at 13:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.