Deep understanding of the Java Virtual machine's fault handling tools _java

Source: Internet
Author: User
Tags stack trace unique id

Objective

This article is mainly to introduce the Java Virtual machine fault handling tools, the article mentioned that these tools include:

Name Main role
JPs JVM process Status Tool, which displays all hotspot virtual machine processes within the specified system. Typically a local host
Jstat JVM Statistics monitoring Tool for collecting operational data for all aspects of hotspot virtual machines
Jinfo Configuration info for Java, displaying virtual machine configuration information
Jmap Memory Map for Java, generating memory snapshots of virtual machines (heapdump files)
Jhat JVM Heap Dump Browser, which is used to parse the Heapdump file, to create a http/html server that allows users to view the analysis results on the browser
Jstack Stack Trace for Java, displaying a snapshot of the virtual machine's threads

JPS: Virtual Machine process Status Tool

The JPS function is similar to the PS command in Unix/liunx. It simply prints out the running virtual machine process and displays the name of the virtual machine executing the main class and the unique ID of the local virtual machine for those processes (the Machine Identifier, Lvmid, usually the system process ID).

JPS command format:

JPS [Options] [hostId]

JPS can open the remote virtual machine process State of the RMI service through the RMI Protocol query, HostID the host name registered in the RMI registry.

JPS Other common options:

-Q Output Only Lvmid, omit the name of the main class;

-m outputs a parameter that is passed to the main class main () function when the virtual machine process starts;

-L OUTPUT The full name of the main class, if the process is executing a jar package, output jar path;

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

JPS Command Sample:

[Root@localhost ~]# jps-l
3914 org.zhangyoubao.payservice.App 12180 sun.tools.jps.Jps
6913 Org.zhangyoubao.userprofiler.App

Jstat: Virtual machine statistical information monitoring tool

Jstat is a tool used to monitor various running state information for a virtual machine. It can display run-time parameters such as load, memory Gc.jit, and so on in a local or remote virtual machine process.

Jstat command format:

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

Interval and count represent the query interval and the number of times. If these two arguments are omitted, only one query is queried.

Jstat Other common options:

-class Monitoring class Load/unload quantity, total space already loaded time;

-compiler output JIT compiler compiled methods, time-consuming and other information;

-printcompilation output has been JIT-compiled method;

-GC monitor Java heap status;

-gccapacity monitoring content is basically the same as-GC, but the output is focused on the maximum/minimum space in each area of Java;

-gcutil monitoring content and-GC are basically the same, but the output is concerned about the use of space to occupy the hundred-percent ratio;

-gccause As with the-gcutil function, the extra output causes the last GC to occur;

-gcnew monitoring of the Cenozoic GC status;

-gcnewcapacity monitoring Cenozoic, output with-gccapacity;

-gcold monitoring of old age GC status;

-gcoldcapacity monitor the old age, output with-gccapacity;

-gcpermcapactiy Monitor the permanent Generation (code area), output with-gccapacity;

Jstat Command Sample:

[Root@localhost ~]# jstat-gc 6913 s0c s1c (s0u s1u  EC  EU  OC   OU  PC  PU ygc  ygct FGC C9/>GCT 
34048.0 34048.0 0.0 3217.8 272640.0 171092.7 683264.0 168910.7 46872.0 28031.2 37857 380.644  3.447 38 4.091

Jinfo:java Configuration Information tool

The role of Jinfo is to view and adjust the virtual machine parameters in real time.

Jinfo Command format:

jinfo [option] pid

Jinfo Other common options:

-flag Name=value Modify Parameters

-flag Name parameter parameter

Jinfo Command Sample:

[Root@localhost ~]# jinfo 6913
attaching to
process ID 6913. Debugger attached successfully.
Server compiler detected.
JVM version is 24.91-b01
Java System Properties:
....

VM Flags:

-xms1000m-xmx1000m-dconf=/usr/local/user_profiler/conf-dserver.root=/usr/local/user_profiler- Dcom.sun.management.jmxremote.port=7003-dcom.sun.management.jmxremote.ssl=false- dcom.sun.management.jmxremote.authenticate=false-verbose:gc-xx:+printgcdetails-xx:+printgcdatestamps-xx:+ Useconcmarksweepgc

Jmap:java Memory Mapping Tool

The Jmap command can be used for production heap storage snapshots (dump files). It can also look up the details of the finalize queue (the self rescue queue), the Java heap, and the code area.

JMAP command format:

jmap [option] Vmid

Jmap Other common options:

-dump generates Java heap storage snapshots. Format:-dump:[live,]format=b,file=<filename>;

-finalizerinfo displays objects in F-queue that wait for the finalizer to execute the Finalize method;

-HEAP Displays Java heap details, such as which type of collector to use, parameter configuration, generational status waiting;

-histo displays the object statistic information in the heap, including class, instance book, Total capacity;

-PERMSTAT displays permanent memory information to classloader for statistic entrance;

-F You can use this option to force a dump snapshot when the virtual machine process heap-dump option is not responding.

Jmap Command Sample:

 root@localhost ~]# jmap-histo 6913|head-20 num #instances #bytes class name---- ------------------------------------------1:1864966 113459432 [C 2:201846 49201192 [B 3:1597065 38329560 Java . lang. String 4:117477 15037056 org.zhangyoubao.thriftdef.UserUsefulInfo 5:47104 11072048 [l 6:268631 8596192 java.u Til. Hashmap$entry 7:48812 7451760 <constMethodKlass> 8:100683 6443712 com.mysql.jdbc.connectionpropertiesimpl$b Ooleanconnectionproperty 9:48812 6257856 <methodKlass> 10:4230 5271640 <constantPoolKlass> 11:159 491 5103712 java.util.hashtable$entry 12:120226 4809040 org.zhangyoubao.common.cache.adv.Node 13:127027 4064864 J Ava.util.concurrent.concurrenthashmap$hashentry 14:230433 3686928 Java.lang.Integer 15:3765 3049824  oolcacheklass> 16:20917 3012048 Com.mysql.jdbc.Field 17:4230 2943840 <instanceklassklass> 

Among them [C=char[],[B=byte[],[S=short[],[I=int[],[[I=int[][] .

Jhat: Virtual machine heap dump snapshot analysis tool

The Jhat command is used in combination with JMAP to analyze the dump file generated by Jmap. Jhat built-in a miniature http/html server that generates the analysis results of the dump file that can be viewed in the browser.

Jhat command format:

Jmap filename

Jhat Command Sample:

[Root@localhost ~]# jhat html_intercept_server.dump 
Reading from Html_intercept_server.dump ...
Dump file created Wed Nov 13:05:33 CST 2016
Snapshot read, resolving ...
Resolving 203681 objects
... Chasing references, expect dots ... ....... ....... ...... ..... ...... .....
... Eliminating duplicate references ....... ...... ..... ..... ..... ..... ....
.. ... Snapshot resolved.
Started HTTP server on the port 7000
server is ready.

Jstack:java Thread Stack Trace tool

Jstack is used to generate a snapshot of the thread at the current moment of the virtual machine. A thread snapshot is the method stack plan that each thread of the current virtual machine is executing, and the primary purpose of generating a thread snapshot is to locate the reason for the long pause in the thread. When a thread pauses, it is through jstack to see what the unresponsive threads do in the background, or what resources are waiting for.

Jstack command format:

jstack [option] Vmid

Jstack Other options:

-F forces the output thread stack when the normal output request is not answered;

-L Displays additional information about the lock in addition to the display stack;

-M If you call the local method, you can display the C/C + + stack.

Jstack Command Sample:

[Root@localhost ~]# jstack 29577|head-20 2016-11-23 12:58:23 full thread dump OpenJDK Server VM (24.91-b01 mixed mode): "pool-1-thread-7261" prio=10 tid=0x0893a400 nid=0x6b0d waiting on condition [0x652ad000] Java.lang.Thread.State:TIMED_ Waiting (parking) at Sun.misc.Unsafe.park (Native method)-Parking to wait for <0x75b5b400> (a Java.util.concurr Ent. Synchronousqueue$transferstack) at Java.util.concurrent.locks.LockSupport.parkNanos (locksupport.java:226) at Java.util.concurrent.synchronousqueue$transferstack.awaitfulfill (synchronousqueue.java:460) at Java.util.concurrent.synchronousqueue$transferstack.transfer (synchronousqueue.java:359) at Java.util.concurrent.SynchronousQueue.poll (synchronousqueue.java:942) at Java.util.concurrent.ThreadPoolExecutor.getTask (threadpoolexecutor.java:1068) at Java.util.concurrent.ThreadPoolExecutor.runWorker (threadpoolexecutor.java:1130) at Java.util.concurrent.threadpoolexecutor$worker.run (threadpoolexecutor.java:615) atJava.lang.Thread.run (thread.java:745) "service_hot_lscs-0" daemon prio=10 tid=0x6982dc00 Nid=0x6aeb waiting on condition [0x64ce1000] Java.lang.Thread.State:TIMED_WAITING (sleeping) at Java.lang.Thread.sleep (Native method) at O Rg.zhangyoubao.video.client.runner.SimpleVideoRunner.doWork (simplevideorunner.java:150)

Summarize

The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring certain help, if you have questions you can message exchange.

Related Article

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.