Blog Post

Apps on Azure Blog
1 MIN READ

Collect Thread Dump and Heap Dump on Linux App Service (Java/Tomcat)

gaukazure's avatar
gaukazure
Icon for Microsoft rankMicrosoft
Sep 09, 2022

The following steps can be followed for both our Java and Tomcat offerings on Linux App Service. Note that, if you are using a custom image, you could enable webSSH and collect dumps using jcmd, if present.

 

1. Go to the Kudu Site of the WebApp via Advanced Tools blade:

 

 

2. Click on SSH to ssh into the Application Container:

 

3. Get the PID of the Java Process (your application):

[There are multiple ways to get it. We can use ps -ef | grep java | grep -v grep command, or simply run jcmd]

 

 

4. Finally, execute the following command to collect the Thread Dump and save it as a file. 

 

jcmd <PID of Java Process> Thread.print > /home/threaddump


Similarly, to collect the heap dump, run:

jcmd <PID of Java Process> GC.heap_dump /home/heapdump

 

 

Note:

The files under /home are only persistent by default. Consider collecting the dumps under /home or in the mounted location for External Storage (if using BYOS)

 

 

Published Sep 09, 2022
Version 1.0
No CommentsBe the first to comment