Saturday 1 June 2013

Diagnosing Java Application tools

Console tools:

jps -v - lists java processes

jcmd - runs command on the jvm
Some examples:

  • jcmd 31435 VM.version - shows information of the virtual machine of the process with pid 31435
  • jcmd 31435 help - shows possible commands for the process with pid 31435
  • jcmd 31435 Thread.print - prints ThreadDump (same as jstack pid)
  • jcmd 31435 GC.class_histogram - prints statistics of classes in the Heap
  • jcmd 31435 GC.heap_dump file - Dump Heap to the given file
  • jcmd 31435 GC.run - runs Garbage Collection
  • jcmd 31435 VM.uptime - time that process work
  • jcmd 31435 VM.flags - flags of the VM for this process
  • jcmd 31435 VM.system_properties -m properties what process was run with
  • jcmd 31435 VM.command_line - java command that started process
  • jcmd 31435 VM.version - the virtual machine version process was run with

jstat - prints jvm statistics

  • jstat -options - lista all options
  • jstat -gc 3773 1s - prints Garbage Collection info every second for process with pid 3773
  • jstat -class 3773 1s - class loaded stats

jvisualvm - graphical tool monitoring jvm processes. We can see CPU, Thread, Heap usage. It allows comparing Heap Dumps, inspecting all objects and references to them. We can use Sampler and Profiler to check where most of the time is spent and where object are mostly allocated.

jstack -F pid - suspends process in unknown state

No comments: