SUN JDK monitoring and troubleshooting tools

Source: Internet
Author: User
Tags stack trace

Name Main role
JPs

JVM Process Status tool that displays all the hotspot virtual machine processes within the specified system

Jstat JVM Statistics Monitoring tool for collecting operational data for all aspects of the hotspot virtual machine
Jinfo Configuration info for Java, displaying Virtual machine config information
Jmap Memory map for Java, generating a snapshot of the virtual machine's RAM dump (heapdump file)
Jhat

The JVM heap dump browser, used to parse the Heapmap file, builds a http/html server

Allows users to view analysis results on the browser

Jstack Stack trace for Java, displaying a thread snapshot of a virtual machine

JPS: Virtual Machine Process Health tool

You can list the running virtual machine processes and display the virtual machine execution main class name and the local virtual machine unique ID for those processes.

JSP command format JSP [options] [HostID]

JPS can turn on the RMI service's remote virtual machine process state through the RMI protocol, HostID the hostname registered in the RMI registry.

JPS Common options

Property Role
-P Output only Lvmid, omit the name of the main class
-M Parameters passed to the main class main () function when the output virtual machine process starts
-L Output the full name of the main class, if the process is executing a jar package, the output jar path
-V JVM parameters when the output virtual machine process starts
Second, Jstat: virtual machine Statistics information monitoring tool

Jstat is a command-line tool for monitoring the various health status information for a virtual machine. It can display the local or remote virtual machine in the process of the class load, memory, garbage Collection, JIT compilation and other running data, in the absence of GUI graphical interface, just provide a plain text console environment on the server, it will be the run-time positioning virtual machine performance problems of the preferred tool

Jstat command format jstat [option Vmid [interval [s|ms] [count]]

For Vmid and Lvmid in the Ming Lin format, such as the local virtual machine process, Vmid and lvmid are consistent, and if it is a remote virtual machine, the Vmid format should be:

[Protocol:] [//] lvmid[@hostname [:p Ort]/servername]

The parameters interval and count represent the interval and number of queries respectively, and if omitted, the description is queried only once.

Main options

Options Role

-class

Time spent monitoring load classes, unloading classes, total space, and class loading

-gc

Monitor Java heap status, including Eden Zone, two survivor zones, old age, permanent generation, capacity, used space, GC time totals information

-gccapacity

The monitoring content is basically the same as-GC, but the output focuses on the maximum and minimum space used by each area of the Java heap

-gcutil

The monitoring content is basically the same as-GC, but the output focuses on the percentage of the total space used by the control

-gccause

Same as-gcutil function, but additional output causes the last GC to occur

-gcnew

Monitor the new generation of GC

-gcnewcapacity

Monitoring content is basically the same as-gcnew, the output is mainly concerned with the maximum and minimum space used

-gcold

Monitoring the Age of GC

-gcoldcapacity

Monitoring content is basically the same as-gcold, the output is mainly concerned with the maximum and minimum space used
-gcpermcapacity Maximum and minimum space used for output permanent generation

-compiler

Output JIT-compiled methods, time-consuming information, etc.

-printcompilation

Output a method that has been JIT-compiled

   

Three, Jinfo:java configuration information tool

Jinfo's role is to view and adjust virtual machine parameters in real time. Use the-v parameter of the JPS command to view the specified parameter list when the virtual machine starts, but if you want to know the system defaults for parameters that are not explicitly specified, you have to use the Jinfo-flag option in addition to finding the data

Jinfo format jinfo [option] pid

Jinfo still has a lot of limitations on the Windows platform

Iv. Jmap:java Memory Image Tool

The Jmap command is used to generate a heap dump snapshot. Jmap's role is not just to get a dump file, it can also query the details of the Finalize execution queue, the Java heap, and the permanent generation. such as space usage, what kind of collector is currently used, and so on.

As with the Jinfo command, Jmap under Windows is also subject to a larger limit. In addition to the-dump options for generating dump files and the-histo options for viewing instances of each class, control occupancy statistics are provided for all operating systems, the remaining options are available only under Linux/solaris.

Jmap format jmap [option] Vmid

Options:

Options Role
-dump Generates a Java heap dump snapshot. The format is:-dump:[live,]format=b,file=<filename>, where the live sub-argument indicates whether to dump only the surviving objects
-finalizerinfo Displays the object in F-queue that waits for the finalizer thread to execute the Finalize method. Valid only on Linux/solaris platform
-heap Displays the Java heap details, such as which collector, parameter configuration, generational conditions, etc., that are available under the Linux/solaris platform
-jisto Displays the object statistics in the heap, including classes, instance objects, collection capacity
-permstat Displays the permanent memory status with ClassLoader as the statistical aperture. Valid only on Linux/solaris platform
-F When the virtual machine process does not have a corresponding-dump option. You can use this option to force a dump snapshot to be generated. Valid only on Linux/solaris platform
V. Jhat: Virtual machine heap dump snapshot analysis tool

Sun JDK provides jhat and jmap to analyze heap snapshots generated by dump. The jhat contains a miniature http/html server that can be viewed in a browser after generating analysis results for the dump file.

Examples of usage jhat test1.bin

Test1.bin is the generated dump file.

The results of the analysis are grouped by enclosing units, and the analysis of memory leaks mainly uses the functions of the "Heap histogram" and oql tags. The former can find the object with the largest total capacity in memory. The latter is a standard object query language that uses SQL-like syntax to query statistics on objects in memory.

Vi. Jstack:java Stack Trace Tool

The Jstack command is used to generate a thread snapshot of the current moment of the virtual machine. The thread snapshot is the collection of method stacks that each thread in the current virtual machine is executing, and the primary purpose of generating the thread snapshot is to locate the cause of the thread's long pause, such as thread deadlock, dead loop, request external resources causing long waits, and so on.

Jstack format jstack [option] Vmid

The legal value and specific meaning of option options

Options Role
-F Forces the output thread stack when a normal output request is not responded to
-L Displays additional information about the lock, in addition to the stack
-M If you call the local method, you can display the C + + stack

The tread class has a new Getallstacktraces () method that gets the Stacktraceelement object for all the threads in the virtual machine.

This essay is just a note of the contents of the book excerpt, in fact, there are many visual convenient tools can be used, such as jconsole to complete the majority of functions, here only to do the memo, do not delve into.

SUN JDK monitoring and troubleshooting tools

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.