JVM performance monitoring and Troubleshooting command Rollup (JPS, Jstat, Jinfo, Jmap, Jhat, Jstack)

Source: Internet
Author: User
Tags stack trace

For a system to locate the problem, knowledge, experience is the key foundation, the data is the basis, the tool is the use of knowledge processing data means

The use of appropriate virtual machine monitoring and analysis tools can speed up our analysis of data, positioning the speed of problem-solving, this article mainly introduces several services

Command-line tools (JPS, Jstat, Jinfo, Jmap, Jhat, jstack) commonly used on the

JPS: Virtual Machine Process Health tool

The JPS (JVM Process Status Tool), in addition to the PS command named UNIX, also functions like the PS command , You can list the virtual machine processes that are running, and displays the virtual machine execution main class.

The format and common parameters are as follows:

Jps[options][hostid]

-L outputs the main class name, if the process is a jar package, the output package path
-V outputs the specified JVM parameters when the virtual machine starts
-Q outputs only LVMID, omitting the main class name

Example:

  

Jstat: Virtual Machine Statistics monitoring tool

The jstat (JVM Statistics monitoring tool) is a command-line utility for monitoring the various health state information of a virtual machine. It can display runtime data such as class loading, memory, garbage Collection, JIT compilation, and so on, in a local or remote virtual machine process .

The format is as follows:

Jstat[option Vmid[interval[s|ms][count]]

-GC monitor Java heap status, including Eden Zone, two survivor zone, old age, permanent generation, etc. capacity, used space, GC time totals information
-class Monitor class load, unload quantity, total space, and time spent on class loading
-gcnew monitoring of the new generation GC
-gcold monitoring the old GC situation
-compiler output JIT compiler compiled methods, time-consuming information
-printcompilation output has been JIT-compiled method

Use examples and parsing:

  

For example, where 13495 represents the PID,250 representative every 250 milliseconds to check the garbage collection status, 20 for the total query 20 times.

The meanings of the columns in the printed content we can see through the man jstat command:

  

Jinfo:java Configuration Information tool

  Jinfo (Configuration Info for Java) the function is to view and adjust the virtual machine parameters in real time. The-v parameter of the JPS command allows you to view the list of parameters that are explicitly specified when the virtual machine starts , but if you want to know the system defaults for parameters that are not explicitly specified, you will need to use the Jinfo command.

The format is as follows:

Jinfo[option]pid

-flag output virtual machine startup parameter parameters
-sysprops Print the contents of the system.getproperties () of the virtual machine process

Examples are as follows:

  

Jmap:java Memory Imaging Tool

The jmap (Memory Map for Java) command is typically used to generate a heap dump snapshot (commonly known as a heapdump or dump file). This command is used more than just to get the dump file, it can also query the details of the Finalize execution queue, the Java heap, and the permanent generation, such as the space usage, which collector is currently used, and so on.

Use the following:

Jmap[option]vmid

-dump generating a dump snapshot of Java
-histo Display statistics for objects in the heap, including class, number of instances, total quantity, etc.
-HEAP displays details of the Java heap, such as which collector to use, parameter configuration, generational situation, etc.
-clstats Display permanent memory status with ClassLoader as statistical aperture
-finalizerinfo shows objects in F-queue waiting for finalizer thread to execute finalizer method

This command is used in many ways, for example:

When a memory overflow occurs on the system, we can use this command to query the count of instances of the surviving classes in the current JVM heap:

  

We can also use this command to generate a virtual machine dump Snapshot file:

  

Other parameters will not be tested, interested students can try their own.

Jhat: Virtual machine heap Dump snapshot analysis tool, used in conjunction with JMAP

  The Sun JDK provides the jhat (JVM heap Analysis Tool) command to use with Jmap to analyze the Jmap-generated heap Dump the snapshot. The jhat contains a miniature http/html server that can be viewed in a browser after generating analysis results for the dump file .

Using commands (Jhat item.bin)

The screen displays "Server is ready." Prompt, the user types http://localhost:7000/in the browser to see the results of the analysis, as shown in:

  

  

Jstack:java Stack Trace Tool

    the Jstack (Stack Trace for Java) command is used to generate a thread snapshot of the current moment of the virtual machine (commonly referred to as a threaddump or Javacore file). A thread snapshot is a collection of method stacks that each thread in the current virtual machine is executing, and the primary purpose of generating a thread snapshot is to locate the cause of a thread's long pauses, such as inter-thread deadlocks, dead loops, Long waits such as requests for external resources are a common cause of long pauses in threads. When a thread pauses, you can see the call stack of each thread by Jstack, and you know what the unresponsive thread is doing in the background, or what resources are waiting for it.

The format is as follows:

Jstack[option]vmid

-F force Output thread stack when the normal output request is not appropriate
-L Display additional information about the lock in addition to the stack
-M if the local method is called, you can display the C/C + + stack

Examples are as follows:

  

  There is no perfect program in the world, but we are not frustrated because writing a program is a process that is constantly striving for perfection.

  

The END.

JVM performance Monitoring and Troubleshooting command Rollup (JPS, Jstat, Jinfo, Jmap, Jhat, Jstack)

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.