Quick Troubleshooting Tips on Windows for Java SE 5.0

This "Quick Start Guide" gives you some quick tips for troubleshooting. The subsections list some typical functions that can help you in troubleshooting, including one or more ways to get the information or perform the action.

These tips are organized as follows:

Hung, Deadlocked, or Looping Process
Post-mortem Diagnostics, Memory Leaks
Monitoring
Other Functions

Hung, Deadlocked, or Looping Process

  • Print thread stack for all Java threads:
    • Control-Break
  • Detect deadlocks:
    • Print information on deadlocked threads: Control-Break
  • Get a heap histogram for a process:
    • Start Java process with -XX:+PrintClassHistogram, then Control-Break
  • Create a heap dump:
    • Start the application with HPROF enabled: java -agentlib:hprof=file= file ,format=b application; on Control-Break, VM generates a heap dump.
    • Start VM with -XX:+HeapDumpOnCtrlBreak; on Ctrl-Break, VM generates a heap dump. (Introduced in Java SE 5.0 update 14.)

Post-mortem Diagnostics, Memory Leaks

  • Examine the fatal error log file. Default file name is hs_err_pid pid .log in the working directory.
  • Create a heap dump:
    • Start the application with HPROF enabled: java -agentlib:hprof=file= file ,format=b application; on Control-Break, VM generates a heap dump.
    • Start the application with HPROF enabled: java -agentlib:hprof=heap=dump application
    • Start VM with -XX:+HeapDumpOnOutOfMemoryError; if OutOfMemoryError is thrown, VM generates a heap dump. (Introduced in Java SE 5.0 update 7.)
  • Browse Java heap dump:
    • Heap Analysis Tool (HAT)
  • Get a heap histogram for a process:
    • Start Java process with -XX:+PrintClassHistogram, then Control-Break

Monitoring

( jstat is not available on Windows 98 or Windows ME.)

Note: The vmID argument for the jstat command is the virtual machine identifier. See the jstat man page for a detailed explanation.

  • Print statistics on the class loader:
    • jstat -class vmID
  • Print statistics on the compiler:
    • Compiler behavior: jstat -compiler vmID
    • Compilation method statistics: jstat -printcompilation vmID
  • Print statistics on garbage collection:
    • Summary of statistics: jstat -gcutil vmID
    • Summary of statistics, with causes: jstat -gccause vmID
    • Behavior of the gc heap: jstat -gc vmID
    • Capacities of all the generations: jstat -gccapacity vmID
    • Behavior of the new generation: jstat -gcnew vmID
    • Capacity of the new generation: jstat -gcnewcapacity vmID
    • Behavior of the old and permanent generations: jstat -gcold vmID
    • Capacity of the old generation: jstat -gcoldcapacity vmID
    • Capacity of the permanent generation: jstat -gcpermcapacity vmID
  • Monitor objects awaiting finalization:
    • JConsole tool, Memory tab
    • getObjectPendingFinalizationCount method in java.lang.management.MemoryMXBean class
  • Monitor memory:
    • Heap allocation profiles via HPROF: java -agentlib:hprof=heap=sites
    • JConsole tool, Memory tab
    • Control-Break prints generation information.
  • Monitor CPU usage:
    • By thread stack: java -agentlib:hprof=cpu=samples application
    • By method: java -agentlib:hprof=cpu=times application
    • JConsole tool, Overview and VM Summary tabs
  • Monitor thread activity:
    • JConsole tool, Threads tab
  • Monitor class activity:
    • JConsole tool, Classes tab

Other Functions

  • Interface with the instrumented Java virtual machines:
    • Monitor for the creation and termination of instrumented VMs (not Windows 98 or Windows ME): jstatd daemon
    • List the instrumented VMs (not Windows 98 or Windows ME): jps
    • Provide interface between remote monitoring tools and local VMs (not Windows 98 or Windows ME): jstatd daemon
    • Request garbage collection: JConsole tool, Memory tab
  • Report on monitor contention:
    • java -agentlib:hprof=monitor=y application
  • Interface dynamically with an MBean, via JConsole tool, MBean tab:
    • Show tree structure.
    • Set an attribute value.
    • Invoke an operation.
    • Subscribe to notification.
  • Run interactive command-line debugger:
    • Launch a new VM for the class: jdb class
    • Attach debugger to a running VM: jdb -attach address