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
OpenJDK
process. - 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 Runtime
along with its PID.
Generate a Thread Dump
- Using
jstack
1
jstack <pid> > thread-dump.txt
This generates a thread dump in
.txt
format.
Generate a Memory (Heap) Dump
- Using
jmap
1
jmap -dump:live,format=b,file=heap-dump.hprof <pid>
This generates a live heap dump in
HPROF
format.
macOS
Requirements
- JDK installed
- Terminal access with necessary permissions
Finding the PID of Martini Runtime
- Open Terminal and run:
1
jps -l
- Look for a process named
io.toro.martini.launch.Main
and note the<pid>
.
Generate a Thread Dump
- Using
jstack
1
jstack <pid> > thread-dump.txt
This generates a thread dump in
.txt
format.
Generate a Memory (Heap) Dump
- Using
jmap
1
jmap -dump:live,format=b,file=heap-dump.hprof <pid>
This generates a live heap dump in
HPROF
format.sudo
may be required for permissions.
Linux
Requirements
- JDK installed
- Terminal access
Finding the PID of Martini Runtime
- Run the following:
1
jps -l
- Look for the process
io.toro.martini.launch.Main
and get the<pid>
.
Generate a Thread Dump
- Using
jstack
1
jstack <pid> > thread-dump.txt
This generates a thread dump in
.txt
format.
Generate a Memory (Heap) Dump
- Using
jmap
1
jmap -dump:live,format=b,file=heap-dump.hprof <pid>
This generates a live heap dump in
HPROF
format.sudo
may be required for permissions.
Notes
- If you encounter permission issues with
jmap
orjstack
, 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).