简体   繁体   中英

Automating Tomcat Thread/heap dump for further analysis

I am running an web application on tomcat. Tomcat process is getting hung when there are lots of requests fired. Since this is an production web app , i cant monitor all the time to get the tomcat java process/thread dump manually.

I have already enabled the jmx remote port on tomcat

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=2222 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true

My question is : When the tomcat process hits high CPU[thread count]/Memory usage/got Hung , at that point of time can we collect the tomcat thread dump to desired disk location automatically[command line or programatically] ?

These options:

JAVA_OPTS='-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/dir'

will make a core dump when Tomcat runs out of memory.

Also -verbose:gc option might be useful in this case.

B.2.3 -verbose:gc Option

The -verbose:gc option enables logging of garbage collection (GC) information. It can be combined with other HotSpot VM specific options such as -XX:+PrintGCDetails and -XX:+PrintGCTimeStamps to get further information about the GC. The information output includes the size of the generations before and after each GC, total size of the heap, the size of objects promoted, and the time taken.

Troubleshooting Guide for HotSpot VM > Command-Line Options

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