004 Virtual machine performance monitoring and fault handling tools

Source: Internet
Author: User

Tool is located in the JDK under the Bin 1.JDK command line tool monitoring and fault handling tool

①JPS: Virtual Machine Process Health tool
 
   
  
  1. < Span class= "PLN" >jsp command format:
  2. jps [ options ][ < Span data-wiz-span= "Data-wiz-span" style= "FONT-SIZE:1REM;" >hostid ]
JPS can query the status of the remote virtual machine process that opened the RMI service through the RMI protocol, HostID the host name registered in the RMI registry. Other common options for JPS are shown in the table below.

②jstat: The Virtual Machine Statistics monitoring Tool jstat (JVM Statistics monitoring tools) is a command-line tool for monitoring the various health state information for a virtual machine. It can display the class load, memory, garbage collection, JIT compiling and other running data in the process of local or remote virtual machine, on the server without GUI graphical interface, only the plain text console environment, it will be the preferred tool for locating virtual machine performance problem at run time.
  
 
  1. jstat命令格式为:
  2. Jstat[option Vmid[interval[s|Ms][Count]]]
For Vmid and Lvmid in the command format, it is important to note that if it is a local virtual machine process, Vmid is consistent with lvmid, and if it is a remote virtual machine process, the VMID format should be:
 
   
  
  1. [protocol:][//]lvmid[@hostname[:port]/servername]
The parameters interval and count represent the query interval and number of times, and if these two parameters are omitted, the description is queried only once.
Option options represents the virtual machine information that the user wants to query, mainly divided into 3 categories: class loading, garbage collection, run-time compilation status, specific options and functions, please refer to the following table description.

  
 
  1. jstat执行样例
  2. D:\DEVELOP\JAVA\JDK1.6.0_21\bin>Jstat-Gcutil2764
  3. S0 S1 E O P YGC YGCT FGC FGCT GCT
  4. 0.00 0.00 6.20 41.42 47.20 - 0.105 3 0.472 0.577
This server's new-generation Eden Zone (E, which represents Eden) uses 6.2% of the space, two survivor zones (S0, S1, Survivor0, Survivor1) inside are empty, the old age (O, the older) and the permanent generation (P, Represents permanent) uses 41.42% and 47.2% of space respectively. Minor GC (YGC, which represents young GC) 16 times since the program was run, takes 0.105 seconds to complete, 3 times for full GC (FGC, for full GC), and full GC total time spent (FGCT, representing full GC Time) is 0.472 seconds, and all GC (GCT) is 0.577 seconds.

The role of the ③jinfo:java configuration Information tool jinfo (config info for Java) is to view and adjust the virtual machine parameters in real time.
The system defaults for parameters that are not explicitly specified by the virtual machine parameters can only be queried using the Jinfo-flag option (if only JDK 1.6 or later, using java-xx:+printflagsfinal to view parameter defaults is also a good choice), Jinfo can also print the contents of the system.getproperties () of the virtual machine process using the-SYSPROPS option.
You can use-flag[+|-]name or-flag name=value to modify part of a run-time writable virtual machine parameter value.

The ④jmap Memory Image tool Jmap (storage Map for Java) command is used to generate a heap dump snapshot (commonly referred to as a heapdump or dump file). If you do not use the Jmap command, to obtain a Java heap dump snapshot, there are some more "brute force" means: such as the-xx:+heapdumponoutofmemoryerror parameter, you can let the virtual machine automatically generate dump files after the oom exception, through the-xx:+ The Heapdumponctrlbreak parameter allows the virtual machine to generate a dump file using the [Ctrl]+[break] key, or it can get a dump file by sending a process exit signal under the Linux system via the Kill-3 command.
Jmap's role is not 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 space usage, which collector is currently in use, and so on.
 
   
  
  1. jmap命令格式:
  2. jmap[option]vmid
The legal values of option options and their specific meanings are shown in the following table:

⑤jhat: Virtual machine heap Dump snapshot analysis tool (typically no, better analysis tools VISUALVM, Eclipse Memory Analyzer, IBM heapanalyzer, etc.) Sun JDK provides jhat (JVM heap analyses Tool) command is used with Jmap to analyze jmap generated heap dump snapshots. The jhat contains a miniature http/html server that can be viewed in a browser after generating analysis results for the dump file.

The ⑥jstack:java 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 the thread snapshot is to locate the cause of a long pause on threads, such as inter-thread deadlocks, dead loops, long waits that are caused by requests for external resources, and so on, which are common causes of long-running threads.
 
   
  
  1. jstack命令格式:
  2. jstack[option]vmid
The legal values for option options and their specific meanings are shown in the following table.

⑦hsdis:jit generate code Disassembly Hsdis is an anti-assembler of Sun's officially recommended hotspot virtual machine JIT-compiled code
Its role is to have the-xx:+printassembly directive of the hotspot call it to restore the dynamically generated native code to the assembly code output, while generating a number of very valuable annotations

2. JDK Visualizer JConsole and VISUALVM two visualization tools ①jconsole:java monitoring and Management console JConsole (Java monitoring and Management Console) is a JMX-based visual monitoring and management tool. The functionality of its Management section is managed for JMX Mbean, because Mbean can be accessed using code, the management console of the middleware server, or all JMX-compliant software
1> start Jconsolejdk "Jconsole.exe" in the bin and automatically search for all virtual machine processes that are running on this computer
2> memory monitoring is equivalent to a visual jstat used to monitor the trend of changes in the memory of virtual machines managed by collectors (Java heap and permanent generation).

3> thread monitoring is equivalent to visualizing jstack can use this tab for monitoring analysis when encountering thread pauses

②VISUALVM: In addition to running monitoring, troubleshooting, many other features are available in the multiple-in-a-way fault-handling tool. such as performance analysis (Profiling), VISUALVM performance analysis function even compared to Jprofiler, Yourkit and other professional and charge Profiling tools are not inferior to how much, And there's a big advantage to VISUALVM: The program doesn't need to be monitored to run on a special agent, so it has little impact on the actual performance of the application, allowing it to be applied directly to the production environment.
VISUALVM is based on the NetBeans platform, so it has the feature of plug-in extension in the first place, and with plug-in extension support, VISUALVM can do:
    • Displays virtual machine processes and process configuration, environment information (JPS, Jinfo).
    • Monitor the application's CPU, GC, heap, method area, and thread information (Jstat, Jstack).
    • Dump and analyze heap dump snapshots (Jmap, jhat).
    • Method-level program run performance analysis to find the most frequently called and longest running methods.
    • Offline Program Snapshot: The collection program runtime configuration, thread dump, memory dump and other information to establish a snapshot, you can send the snapshot to the developer for bug feedback.
    • The infinite possibilities of other plugins ...
After JDK 1.5, the virtual machine in client mode joins and automatically turns on class sharing-- This is an optimization that shares Rt.jar class data in a multi-virtual machine process to increase loading speed and memory savings, while the profiler functionality of VISUALVM may crash due to class sharing because of the fact that it is shared, so it is best to be in a monitored program before the reader is profiling. Use the-xshare:off parameter to turn off class sharing optimizations.



From for notes (Wiz)

004 Virtual machine performance monitoring and fault handling 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.