How to get Thread dump and Heap Dump of JVM to analyze the usage of WSO2 ESB
1 min readDec 13, 2023
[Article moved from ajanthane.blogspot.com]
To get the Thread dump or Heap dump of the WSO2 ESB, first we need to find the process id of it.
Execute the below command to get the process id:
esb-support@esbsupport-Latitude-E5450:~/ajanthan$ ps -aux | grep 'bootstrap'
This will output as below:
esb-sup+ 11366 0.9 9.4 3636940 763548 pts/4 Sl+ Nov23 2:03 /usr/lib/jvm/java-7-oracle/bin/java -Xbootclasspath/a: -Xms256m -Xmx1024m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/esb-support/ajanthan/wso2esb-4.8.1-2/repository/logs/heap-dump.hprof -Dcom.sun.management.jmxremote -classpath /usr/lib/jvm/java-7-oracle/lib/tools.jar:/home/esb-support/ajanthan/wso2esb-4.8.1-2/bin/org.wso2.carbon.bootstrap-4.2.0.jar:/home/esb-support/ajanthan/wso2esb-4.8.1-2/bin/tcpmon-1.0.jar:/home/esb-support/ajanthan/wso2esb-4.8.1-2/bin/tomcat-juli-7.0.34.jar:/home/esb-support/ajanthan/wso2esb-4.8.1-2/lib/commons-lang-2.6.0.wso2v1.jar -Djava.endorsed.dirs=/home/esb-support/ajanthan/wso2esb-4.8.1-2/lib/endorsed:/usr/lib/jvm/java-7-oracle/jre/lib/endorsed:/usr/lib/jvm/java-7-oracle/lib/endorsed -Djava.io.tmpdir=/home/esb-support/ajanthan/wso2esb-4.8.1-2/tmp -Dcatalina.base=/home/esb-support/ajanthan/wso2esb-4.8.1-2/lib/tomcat -Dwso2.server.standalone=true -Dcarbon.registry.root=/ -Djava.command=/usr/lib/jvm/java-7-oracle/bin/java -Dcarbon.home=/home/esb-support/ajanthan/wso2esb-4.8.1-2 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path=/home/esb-support/ajanthan/wso2esb-4.8.1-2/repository/conf -Djava.util.logging.config.file=/home/esb-support/ajanthan/wso2esb-4.8.1-2/repository/conf/etc/logging-bridge.properties -Dcomponents.repo=/home/esb-support/ajanthan/wso2esb-4.8.1-2/repository/components/plugins -Dconf.location=/home/esb-support/ajanthan/wso2esb-4.8.1-2/repository/conf -Dcom.atomikos.icatch.file=/home/esb-support/ajanthan/wso2esb-4.8.1-2/lib/transactions.properties -Dcom.atomikos.icatch.hide_init_file_path=true -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Djava.security.egd=file:/dev/./urandom -Dfile.encoding=UTF8 org.wso2.carbon.bootstrap.Bootstrap
esb-sup+ 18783 0.0 0.0 13700 2288 pts/18 S+ 01:57 0:00 grep --color=auto bootstrap
Thread Dump
esb-support@esbsupport-Latitude-E5450:~/ajanthan$ jstack <PID> >> thread_dump.log
Heap Dump
esb-support@esbsupport-Latitude-E5450:~/ajanthan$ jmap -dump:file=heap_dump.bin <PID>