Get thread dump and heap dump for MID Server
On rare occasions when a MID Server cannot or is slow to pick up messages from the instance, you would like to get a thread dump to troubleshoot. This article describes how to do so. Note that you need to have login access to the MID Server.
How to get thread dump and heap dump
Download and install a JDK compatible with the MID Server JRE to get the jstack.exe executable from the JDK.
You might run into some unsupported JVM version exceptions if you install the wrong JDK version.
Download and unzip PSTools: https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx. You might not have to do this but PsExec is needed to invoke jstack.exe on a process that is run as Local System, which is typical when the MID Server is run as a Windows service.
Open the windows console as administrator and run the following command to get the MID Server PID.
Note that there might be multiple Java processes but you should be able to tell which one is the MID Server. The -m option will print out something like "com.service_now.mid.Main" in the output. You can also find the PID in task manager.
psexec -s jps -l -m
If multiple MID Servers are running, use following command to track down the parent PIDs to see which one matches the wrapper.
wmic process where (processid=PID_HERE) get parentprocessid
Run the following command to get the MID Server thread dump.
psexec -s jstack -l PID_HERE > threadDump.txt
Run following command to get the heap dump.
psexec -s jmap -dump:file=heapDump.bin PID_HERE
Alternately, to dump the heap automatically on out-of-memory exception, modify conf/wrapper-override.conf. (wrapper.app.additional.NUMBER must be next unused number starting from 1. No gaps, no duplicates across both wrapper.conf and wrapper-override.conf.)
jmap - Memory Map – How to use jmap
jstack - Stack Trace – How to use jstack