JVM Diagnostics and Troubleshooting

Production debugging should start with evidence. Useful tools include jcmd, jstack, jmap, Java Flight Recorder, Java Mission Control, and JVM logging facilities.

jcmd <pid> VM.flags
jcmd <pid> GC.heap_info
jcmd <pid> Thread.print
jcmd <pid> JFR.start duration=60s filename=recording.jfr

Thread dumps help identify deadlocks and blocked threads. Heap information helps investigate memory pressure. Flight Recorder captures runtime events for CPU, allocation, locks, I/O, and GC analysis.

The workflow is: observe, collect evidence, form a hypothesis, make a targeted change, and verify.

Key Takeaways
  • Use thread dumps for thread-state problems.
  • Use heap/GC evidence for memory problems.
  • Java Flight Recorder is valuable for correlating CPU, allocation, locks, and GC behavior.