简体   繁体   中英

Setting heap size in Tomcat

I am working on the apache tomcat server in unix enviroment. I want to increase the heap size of my application and so I am setting it in the catalina.sh file. This is how I am doing it...

export CATALINA_OPTS="-Xms1024m -Xmx1024m" echo $CATALINA_OPTS

When i call the startup.sh it calls catalina.sh and sets the variable CATALINA_OPTS to 1024 as indicated by the echo statement in the script. But if I do echo $CATALINA_OPTS at the command prompt it gives blank. Is this expected behavior. How can I be sure that the correct heap value has indeed been picked up?

Yes, $CATALINA_OPTS will not be available outside of the script thats executed by the shell. In order to get the correct heap size, you need a profiler, or use jmap to get heap info - here 39196 is the PID of the tomcat process on my machine.

mpandit-mbp:~ mpandit$ jmap -heap 39196
Attaching to process ID 39196, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 19.1-b02-334

using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 132120576 (126.0MB)
   NewSize          = 21757952 (20.75MB)
   MaxNewSize       = 87228416 (83.1875MB)
   OldSize          = 65404928 (62.375MB)
   NewRatio         = 7
   SurvivorRatio    = 8
   PermSize         = 21757952 (20.75MB)
   MaxPermSize      = 85983232 (82.0MB)

$ ps aux | grep tomcat $ ps aux | grep tomcat command should display actual settings picked by tomcat.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM