In depth understanding of fault handling tools for Java virtual machine

preface

This article mainly introduces the fault handling tools of Java virtual machine. These tools include:

JPS: virtual machine process status tool

The function of JPS is similar to the PS command in UNIX / liunx. However, it prints out the running virtual machine processes, and displays the name of the virtual machine execution main class and the local virtual machine unique ID (local virtual machine identifier, lvmid, usually the system process ID) of these processes.

JPS command format:

JPS can query the process status of remote virtual machine with RMI service enabled through RMI protocol. Hostid is the host name registered in RMI registry.

JPS other common options:

-Q only output lvmid and omit the name of the main class;

-M output the parameters passed to the main () function of the main class when the virtual machine process is started;

-L output the full name of the main class. If the process executes a jar package, output the jar path;

-V output the JVM parameters when the virtual machine process starts.

JPS command example:

Jstat: virtual machine statistics monitoring tool

Jstat is a tool for monitoring various running state information of virtual machines. It can display the class load and memory GC in the local or remote virtual machine process JIT and other operating parameters.

Jstat command format:

Interval and count represent query interval and times. If these two parameters are omitted, the query is only performed once.

Jstat other common options:

-Class monitors the number of load / unload classes, the total space, and the loaded time;

-The compiler outputs the method and time-consuming information compiled by the JIT compiler;

-Printcompilation outputs methods that have been JIT compiled;

-GC monitors Java heap status;

-The monitoring content of gccapacity is basically the same as that of - GC, but the output focuses on the maximum / minimum space of each region of Java;

-The monitoring content of gcutil is basically the same as that of - GC, but the output focuses on the percentage of used space;

-Gccause has the same function as - gcutil. Additional output causes the last GC;

-Gcnewmonitor the condition of Cenozoic GC;

-Gcnewcapacity monitors the Cenozoic, and the output is the same as - gccapacity;

-Gcold was used to monitor the GC status of the elderly generation;

-Gcoldcapacity monitors the old age, and the output is the same as - gccapacity;

-Gcperm capactiy monitors the permanent generation (code area), and the output is the same as - gccapacity;

Jstat command example:

Jinfo: Java configuration information tool

Jinfo is used to view and adjust various parameters of the virtual machine in real time.

Jinfo command format:

Jinfo other common options:

-Flag name = value modify parameters

-Flag name parameter

Jinfo command example:

Jmap: Java memory mapping tool

The jmap command can be used to store snapshots (dump files) in the production heap. It can also look up the details of the finalize queue, Java heap and code area.

Jmap command format:

Jmap other common options:

-Dump generates a snapshot of Java heap storage. Format: - dump: [live,] format = B, file = < filename >;

-Finalizerinfo displays the objects in the f-queue waiting for finalizer to execute the finalize method;

-Heap displays Java heap details, such as which collector to use, parameter configuration, generation status, etc;

-Histo displays the statistical information of objects in the heap, including class, instance book and total capacity;

-Permstat displays the permanent generation memory information with classloader as the statistical entry;

-F when the virtual machine process heap dump option does not respond, you can use this option to force the generation of dump snapshots.

Jmap command example:

Where [C = char [], [b = byte [], [S = short [], [i = int [], [[i = int [] []].

Jhat: virtual machine heap dump snapshot analysis tool

The jhat command is used with jmap to analyze the dump file generated by jmap. Jhat has built-in a micro http / HTML server, and the analysis results of the generated dump file can be viewed in the browser.

Jhat command format:

Example jhat command:

Jstack: java thread stack tracing tool

Jstack is used to generate a thread snapshot of the virtual machine at the current time. Thread snapshot is the method stack plan being executed by each thread of the current virtual machine. The main purpose of generating thread snapshot is to locate the cause of thread pause for a long time. When the thread pauses, use jstack to check what the unresponsive thread is doing in the background or waiting for resources.

Jstack command format:

Jstack additional options:

-F force the output thread stack when the normally output request is not responded;

-L in addition to displaying the stack, additional information about the lock is displayed;

-M if you call a local method, you can display the stack of C / C + +.

Jstack command example:

summary

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. If you have any questions, you can leave a message.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>