Generating Thread and Memory Dumps for Different Operating Systems
This guide provides instructions to generate thread dumps and memory (heap) dumps for Java applications running on Windows, macOS, and Linux. These dumps are useful for debugging and performance analysis.
Windows
Requirements
- Java Development Kit (JDK) installed
- Administrator privileges (for certain tools or commands)
Finding the PID of Martini Runtime
Open Task Manager:
- Go to the Processes tab and look for the
OpenJDKprocess. - Right-click it and select Go to details to find the
<pid>.
If Martini Runtime is installed as a service:
- Go to the Services tab in Task Manager and locate
Martini Runtimealong with its PID.
Generate a Thread Dump
- Using
jstack
1jstack <pid> > thread-dump.txtThis generates a thread dump in
.txtformat.
Generate a Memory (Heap) Dump
- Using
jmap
1jmap -dump:live,format=b,file=heap-dump.hprof <pid>This generates a live heap dump in
HPROFformat.
macOS
Requirements
- JDK installed
- Terminal access with necessary permissions
Finding the PID of Martini Runtime
- Open Terminal and run:
1jps -l - Look for a process named
io.toro.martini.launch.Mainand note the<pid>.
Generate a Thread Dump
- Using
jstack
1jstack <pid> > thread-dump.txtThis generates a thread dump in
.txtformat.
Generate a Memory (Heap) Dump
- Using
jmap
1jmap -dump:live,format=b,file=heap-dump.hprof <pid>This generates a live heap dump in
HPROFformat.sudomay be required for permissions.
Linux
Requirements
- JDK installed
- Terminal access
Finding the PID of Martini Runtime
- Run the following:
1jps -l - Look for the process
io.toro.martini.launch.Mainand get the<pid>.
Generate a Thread Dump
- Using
jstack
1jstack <pid> > thread-dump.txtThis generates a thread dump in
.txtformat.
Generate a Memory (Heap) Dump
- Using
jmap
1jmap -dump:live,format=b,file=heap-dump.hprof <pid>This generates a live heap dump in
HPROFformat.sudomay be required for permissions.
Notes
- If you encounter permission issues with
jmaporjstack, try running the command withsudo(macOS/Linux). - If the
<pid>is not showing when runningjps -l, try running the command withsudo. - Analyze heap dumps using tools like Eclipse MAT (Memory Analyzer Tool).