Originally Wiki'd By: Brad Galla 23-Aug-2013 13:36 CDT
This section lists methods to obtain dumps on *nix-based platforms
The 'kill' command on *nix machines will invoke a thread dump when the highest level of killing a process is inflicted. To perform the highest level of kill, and to generate a thread dump of the process that is being eradicated, run the following command:
Command | Level | Explanation |
---|---|---|
kill | -3 | SIGQUIT - Sends a quit command to the process; causes thread dump to stdout |
-9 | SIGKILL - Kills the process; causes thread dump to stdout |
NOTE: -9 WILL TERMINATE PROCESS. USE -3 IF PROCESS TERMINATION IS NOT DESIRED. (see Comments:Dumps From a Java Process page)
OS | Command | Arguments | Description | Java |
---|---|---|---|---|
*nix | jstack (Thread Dump) | -m process-id# | Prints mixed threads (Java & C++) on a specified process ID# | 5 |
jmap (Heap Dump) | process-id# | Performs shared object mappings on the specified process ID# | ||
-heap process-id# | Performs a heap dump on the specified process ID# | |||
-histo process-id# | Prints the histogram for the specified process ID# | |||
jstack (Thread Dump) | -l process-id# | Prints long listing information (locks, synchronizers, etc.) on a specified process ID# | 6, 7 | |
-l -F process-id# | Force a stack dump when jstack isn't responding | |||
jmap (Heap Dump) | -dump:format=b,file=filename process-id# | Dumps the memory map of the target process-ID# to an hprof file within the current directory (or specified directory if you expand upon filename) |
This section lists methods to obtain fresh dumps on Windows-based platforms
Action | Command/Arguments | Description |
---|---|---|
Thread Dump from Console Window | [CTRL]+[BREAK] | This will print the thread dump directly to the console window. This text can then be extracted from the console and thrown in a text-editor for easier reading |
Thread Dump from Windows Service |
at 17:34 cmd /c %JAVA_HOME%\bin\jstack.exe -l process-id# ^>C:\stack.txt 2^>^&1 |
Due to security designs of Windows Services, a scheduled task must be setup to get a dump on a Windows Service. If you run this command from an Administrative Command Prompt, set it for 1 minute ahead of your current time. If you set it after the time has elapsed, it will run the next day instead. You can run "at" without options to make sure your command is scheduled appropriately. See the example below for a screenshot showing how to do this |
OS | Command | Arguments | Description | Java |
---|---|---|---|---|
Windows | ||||
jmap (Heap Dump) | -dump:format=b,file=filename process-id# | Dumps the memory map of the target process-ID# to an hprof file within the current directory (or specified directory if you expand upon filename) | 6, 7 | |
jstack (Thread Dump) | -l process-id# | Prints long listing information (locks, synchronizers, etc.) on a specified process ID# | ||
-l -F process-id# | Force a stack dump when jstack isn't responding |
Command | Java 5 Reference | Java 6 Reference | Java 7 Reference |
---|---|---|---|
jmap | jmap - Memory Map | jmap - Memory Map | jmap - Memory Map |
jstack | jstack - Stack Trace | jstack - Stack Trace | jstack - Stack Trace |
Java 4 does not support jstack.
Java 5 has shown intermittent support on Windows when using jstack. Some notable cases include:
On versions 3.7.5+, you should be able to get an anthill-specific thread dump by navigating to System --> Server Settings --> Diagnostics --> View CPU Thread Usage.
If the JDK is installed (Java 6 or greater), one method for retrieving any type of dump can be done through JVisualVM. JVisualVM is a GUI for analyzing Java processes, as well as getting detailed & intricate info on heaps, available threads, CPU usage, etc. To attempt to get any dumps from JVisualVM:
# | STEP | SCREENSHOT |
---|---|---|
1 | Either through a command prompt, a terminal window, or the Run window, fire up JVisualVM. | |
2 | (OPTIONAL) Perform any calibration if needed. | |
3 | Locate the java process you wish to analyze | |
4 | Click on Applications, and then select an appropriate dump | |
Heap Dump if generating a heap dump (appears in the temp directory) | ||
Thread Dump if generating a thread dump (appears within JVisualVM's thread window) |
An example set of steps to take a thread dump from a Windows Service.
# | STEP | SCREENSHOT |
---|---|---|
1 | Verify what processes are running on the system with both 'jps' and 'Windows Task Manager' | |
2 | Prepare the command in a high-quality text editor | |
3 | Execute the command from an Administrative Command Prompt. Note that it has to be ran under an Administrative Command Prompt for full system access. | |
4 | Verify that scheduled tasks exist. | |
5 | Observe that thread dumps have been created in the location of your choice. | |
6 | Compress & Send in Supportal ticket. |
Any newer AnthillPro server has two server processes:
Please make sure to take dumps of both when dumping!