Monitoring tools
Troubleshooting Tips on Windows
Hung,Deadlocked, Looping Process
Post-Mortem Diagnostics,Memory Leaks
Monitoring
OtherFunctions.
Hung, Deadlocked, or Looping Process
· Print thread stack for all Java threads:
o Control-Break
o jstack pid
· Detect deadlocks:
o Request deadlock detection: JConsole tool, Threads tab
o Print information on deadlocked threads: Control-Break
o Print lock information for a process: jstack -l pid
· Get a heap histogram for a process:
o Start Java process with -XX:+PrintClassHistogram, then Control-Break
o jmap -histo pid
· Dump Java heap for a process in binary format to file:
o jmap -dump:format=b,file= filename pid
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:
o Start the application with HPROF enabled: java -agentlib:hprof=file= file,format=b application; then Control-Break
o Start the application with HPROF enabled: java -agentlib:hprof=heap=dumpapplication
o JConsole tool, MBeans tab
o Start VM with -XX:+HeapDumpOnOutOfMemoryError; if OutOfMemoryError is thrown, VM generates a heap dump.
· Browse Java heap dump:
o jhat heap-dump-file
· Get a heap histogram for a process:
o Start Java process with -XX:+PrintClassHistogram, then Control-Break
o jmap -histo pid
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 jstatman page for a detailed explanation.
· Print statistics on the class loader:
o jstat -class vmID
· Print statistics on the compiler:
o Compiler behavior: jstat -compiler vmID
o Compilation method statistics: jstat -printcompilation vmID
· Print statistics on garbage collection:
o Summary of statistics: jstat -gcutil vmID
o Summary of statistics, with causes: jstat -gccause vmID
o Behavior of the gc heap: jstat -gc vmID
o Capacities of all the generations: jstat -gccapacity vmID
o Behavior of the new generation: jstat -gcnew vmID
o Capacity of the new generation: jstat -gcnewcapacity vmID
o Behavior of the old and permanent generations: jstat -gcold vmID
o Capacity of the old generation: jstat -gcoldcapacity vmID
o Capacity of the permanent generation: jstat -gcpermcapacity vmID
· Monitor objects awaiting finalization:
o JConsole tool, VM Summary tab
o getObjectPendingFinalizationCount method injava.lang.management.MemoryMXBean class
· Monitor memory:
o Heap allocation profiles via HPROF: java -agentlib:hprof=heap=sites
o JConsole tool, Memory tab
o Control-Break prints generation information.
· Monitor CPU usage:
o By thread stack: java -agentlib:hprof=cpu=samples application
o By method: java -agentlib:hprof=cpu=times application
o JConsole tool, Overview and VM Summary tabs
· Monitor thread activity:
o JConsole tool, Threads tab
· Monitor class activity:
o JConsole tool, Classes tab
Other Functions
· Interface with the instrumented Java virtual machines:
o Monitor for the creation and termination of instrumented VMs (not Windows 98 or Windows ME): jstatd daemon
o List the instrumented VMs (not Windows 98 or Windows ME): jps
o Provide interface between remote monitoring tools and local VMs (not Windows 98 or Windows ME): jstatd daemon
o Request garbage collection: JConsole tool, Memory tab
· Dynamically set, unset, or change the value of certain Java VM flags for a process:
o jinfo -flag flag pid
· Pass a Java VM flag to the virtual machine:
o jconsole -J flag ...
o jhat -J flag ...
· Report on monitor contention:
o java -agentlib:hprof=monitor=y application
· Evaluate or execute a script in interactive or batch mode:
o jrunscript
· Interface dynamically with an MBean, via JConsole tool, MBean tab:
o Show tree structure.
o Set an attribute value.
o Invoke an operation.
o Subscribe to notification.
· Run interactive command-line debugger:
o Launch a new VM for the class: jdb class
o Attach debugger to a running VM: jdb -attach address
o Request deadlock detection: JConsole tool, Threads tab
o Print information on deadlocked threads: Control-Break
o Print lock information for a process: jstack -l pid
· Get a heap histogram for a process:
o Start Java process with -XX:+PrintClassHistogram, then Control-Break
o jmap -histo pid
· Dump Java heap for a process in binary format to file:
o jmap -dump:format=b,file= filename pid
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:
o Start the application with HPROF enabled: java -agentlib:hprof=file= file,format=b application; then Control-Break
o Start the application with HPROF enabled: java -agentlib:hprof=heap=dumpapplication
o JConsole tool, MBeans tab
o Start VM with -XX:+HeapDumpOnOutOfMemoryError; if OutOfMemoryError is thrown, VM generates a heap dump.
· Browse Java heap dump:
o jhat heap-dump-file
· Get a heap histogram for a process:
o Start Java process with -XX:+PrintClassHistogram, then Control-Break
o jmap -histo pid
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 jstatman page for a detailed explanation.
· Print statistics on the class loader:
o jstat -class vmID
· Print statistics on the compiler:
o Compiler behavior: jstat -compiler vmID
o Compilation method statistics: jstat -printcompilation vmID
· Print statistics on garbage collection:
o Summary of statistics: jstat -gcutil vmID
o Summary of statistics, with causes: jstat -gccause vmID
o Behavior of the gc heap: jstat -gc vmID
o Capacities of all the generations: jstat -gccapacity vmID
o Behavior of the new generation: jstat -gcnew vmID
o Capacity of the new generation: jstat -gcnewcapacity vmID
o Behavior of the old and permanent generations: jstat -gcold vmID
o Capacity of the old generation: jstat -gcoldcapacity vmID
o Capacity of the permanent generation: jstat -gcpermcapacity vmID
· Monitor objects awaiting finalization:
o JConsole tool, VM Summary tab
o getObjectPendingFinalizationCount method injava.lang.management.MemoryMXBean class
· Monitor memory:
o Heap allocation profiles via HPROF: java -agentlib:hprof=heap=sites
o JConsole tool, Memory tab
o Control-Break prints generation information.
· Monitor CPU usage:
o By thread stack: java -agentlib:hprof=cpu=samples application
o By method: java -agentlib:hprof=cpu=times application
o JConsole tool, Overview and VM Summary tabs
· Monitor thread activity:
o JConsole tool, Threads tab
· Monitor class activity:
o JConsole tool, Classes tab
Other Functions
· Interface with the instrumented Java virtual machines:
o Monitor for the creation and termination of instrumented VMs (not Windows 98 or Windows ME): jstatd daemon
o List the instrumented VMs (not Windows 98 or Windows ME): jps
o Provide interface between remote monitoring tools and local VMs (not Windows 98 or Windows ME): jstatd daemon
o Request garbage collection: JConsole tool, Memory tab
· Dynamically set, unset, or change the value of certain Java VM flags for a process:
o jinfo -flag flag pid
· Pass a Java VM flag to the virtual machine:
o jconsole -J flag ...
o jhat -J flag ...
· Report on monitor contention:
o java -agentlib:hprof=monitor=y application
· Evaluate or execute a script in interactive or batch mode:
o jrunscript
· Interface dynamically with an MBean, via JConsole tool, MBean tab:
o Show tree structure.
o Set an attribute value.
o Invoke an operation.
o Subscribe to notification.
· Run interactive command-line debugger:
o Launch a new VM for the class: jdb class
o Attach debugger to a running VM: jdb -attach address
Monitoring Tools
Java VisualVM
Java™ VisualVM is a new monitoring and profiling tool for troubleshooting Java applications. It incorporates various technologies, including jvmstat and JMX, as well as CPU and memory profiling, to provide one easy-to-use integrated visualization tool. Developers can rapidly create their own extensions using a public API, and may share them with the community on a central repository.
· Display local and remote Java applications.
· Display application configuration and runtime environment.
· Monitor application memory consumption and runtime behavior.
· Monitor application threads.
· Profile application performance or analyze memory allocation. (Local applications only.)
· Create and display thread dumps.
· Create and browse heap dumps.
· Analyze core dumps.
· Analyze applications offline.
· Get additional plugins contributed by the community.
· Write and share your own plugins.
JConsole
Launch a GUI to monitor and manage Java applications and Java VMs on a local or remote machine.
· Connection to Java process, host, or JMX agent.
· Graphical overview of CPU usage, heap memory, threads, classes.
· Summary of key data, for example, uptime, compilation time, objects pending finalization, and more.
· Memory statistics, including garbage collection.
· Request garbage collection.
· Thread statistics.
· Deadlock detection.
· Class statistics.
· Tree structure of all platform and application MBeans.
· Set the value of an MBean attribute.
· Invoke operation on an MBean, for example, perform a heap dump.
· Subscribe to notification for an MBean.
· Information about the virtual machine, the compiler, the operating system.
· Pass flags to VM on which JConsole is running.
jps
List instrumented Java virtual machines.
jstat
Display performance statistics for an instrumented Java VM:
· Behavior of the class loader
· Behavior of the HotSpot Just-in-Time compiler, totals and by method
· Behavior of the GC heap
· Behavior and sizes of the generation areas
jstatd
· Monitor for creation and termination of instrumented HotSpot Java VMs.
· Provide an interface for remote monitoring tools to attach to Java VMs.
Debugging Tools
HPROF profiler
Writes class profiling information to a file or a socket, in ASCII or binary.
· Heap allocation profiling.
· Heap dump.
· CPU usage - for threads, methods.
· Monitor contention profiling.
To invoke the HPROF tool: java -agentlib:hprof ToBeProfiledClass
To print the complete list of options: java -agentlib:hprof=help
jdb
Launch a simple interactive command-line debugger.
· Display Java objects and primitive values.
· List currently running threads.
· Dump the current thread stack.
· Set breakpoints.
· Step through execution.
· Examine exceptions.
jhat
Parse a binary heap dump, launch a web browser, and present standard queries.
· Execute standard queries, for example, classes, objects, class instances, reference chains from object rootset, reachable objects, and more.
· Turn on or off object allocation tracking.
· Turn on or off object reference tracking.
· Specify objects to exclude from "reachable objects" query.
· Pass flags to the Java VM on which jhat is running.
· Develop custom queries with buit-in Object Query Language.
· Compare objects in two dumps.
jinfo
· Print command line flags and system properties for a running process, from a core file, or for a remote debug server.
· Dynamically set, unset, or change the value of certain Java VM flags for a process.
jmap
· Print shared object mappings for a process, a core file, or a remote debug server.
· Dump the Java heap (all objects or only live objects) of a process, a core file, or a remote debug server in binary format to a file.
· Force the Java heap dump of a process if the process does not respond.
· Print a heap summary for a process, a core file, or a remote debug server.
· Print a histogram (all objects or only live objects) of a process, a core file, or a remote debug server.
· Print information on objects awaiting finalization.
· Print class loader statistics of the permanent generation.
· Pass flags to the VM.
jsadebugd
Serviceability Agent Debug Daemon, which acts as debug server.Java™ VisualVM is a new monitoring and profiling tool for troubleshooting Java applications. It incorporates various technologies, including jvmstat and JMX, as well as CPU and memory profiling, to provide one easy-to-use integrated visualization tool. Developers can rapidly create their own extensions using a public API, and may share them with the community on a central repository.
· Display local and remote Java applications.
· Display application configuration and runtime environment.
· Monitor application memory consumption and runtime behavior.
· Monitor application threads.
· Profile application performance or analyze memory allocation. (Local applications only.)
· Create and display thread dumps.
· Create and browse heap dumps.
· Analyze core dumps.
· Analyze applications offline.
· Get additional plugins contributed by the community.
· Write and share your own plugins.
JConsole
Launch a GUI to monitor and manage Java applications and Java VMs on a local or remote machine.
· Connection to Java process, host, or JMX agent.
· Graphical overview of CPU usage, heap memory, threads, classes.
· Summary of key data, for example, uptime, compilation time, objects pending finalization, and more.
· Memory statistics, including garbage collection.
· Request garbage collection.
· Thread statistics.
· Deadlock detection.
· Class statistics.
· Tree structure of all platform and application MBeans.
· Set the value of an MBean attribute.
· Invoke operation on an MBean, for example, perform a heap dump.
· Subscribe to notification for an MBean.
· Information about the virtual machine, the compiler, the operating system.
· Pass flags to VM on which JConsole is running.
jps
List instrumented Java virtual machines.
jstat
Display performance statistics for an instrumented Java VM:
· Behavior of the class loader
· Behavior of the HotSpot Just-in-Time compiler, totals and by method
· Behavior of the GC heap
· Behavior and sizes of the generation areas
jstatd
· Monitor for creation and termination of instrumented HotSpot Java VMs.
· Provide an interface for remote monitoring tools to attach to Java VMs.
Debugging Tools
HPROF profiler
Writes class profiling information to a file or a socket, in ASCII or binary.
· Heap allocation profiling.
· Heap dump.
· CPU usage - for threads, methods.
· Monitor contention profiling.
To invoke the HPROF tool: java -agentlib:hprof ToBeProfiledClass
To print the complete list of options: java -agentlib:hprof=help
jdb
Launch a simple interactive command-line debugger.
· Display Java objects and primitive values.
· List currently running threads.
· Dump the current thread stack.
· Set breakpoints.
· Step through execution.
· Examine exceptions.
jhat
Parse a binary heap dump, launch a web browser, and present standard queries.
· Execute standard queries, for example, classes, objects, class instances, reference chains from object rootset, reachable objects, and more.
· Turn on or off object allocation tracking.
· Turn on or off object reference tracking.
· Specify objects to exclude from "reachable objects" query.
· Pass flags to the Java VM on which jhat is running.
· Develop custom queries with buit-in Object Query Language.
· Compare objects in two dumps.
jinfo
· Print command line flags and system properties for a running process, from a core file, or for a remote debug server.
· Dynamically set, unset, or change the value of certain Java VM flags for a process.
jmap
· Print shared object mappings for a process, a core file, or a remote debug server.
· Dump the Java heap (all objects or only live objects) of a process, a core file, or a remote debug server in binary format to a file.
· Force the Java heap dump of a process if the process does not respond.
· Print a heap summary for a process, a core file, or a remote debug server.
· Print a histogram (all objects or only live objects) of a process, a core file, or a remote debug server.
· Print information on objects awaiting finalization.
· Print class loader statistics of the permanent generation.
· Pass flags to the VM.
jsadebugd
· Attach to a Java process or a core file.
· Remote clients can attach to the server using RMI.
jstack
· Print stack traces of threads for a process, core file, or remote debug server
· Print information about concurrent locks for a process, core file, or remote debug server
· Force the stack dump for a process if the process does not respond
Scripting Tools
jrunscript
· Command-line script shell: Evaluate or execute a script in interactive or batch mode.
· Pass flag to the VM.
· Set Java system properties.
Comments
Post a Comment