Java Virtual Machine monitoring commands

Source: Internet
Author: User
Tags unique id

People familiar with Java know that there are many gadgets in the bin directory of the JDK, including tools for monitoring virtual machines and troubleshooting, and today we'll take a closer look at the usage of each tool.

JPs

JVM process Status Tool for displaying all hotapot virtual machine processes within a specified system

1. Usage

JPS [Options] [HostID]

2. Parameter list

Q: Output only lvmid, omit the name of the main class M: outputs the parameters of the main class main () function when the virtual machine process is started: outputs the full name of the main class. If the process is executing a jar package, the output jar path V: the JVM parameter when the output virtual machine process starts

3. Practical Examples:

1. Jps-q: Output Lvmid only, omit the name of the main class

2. Jps-m: Output The parameters passed to the main class main () function when the virtual machine process starts

3.jps-l: Outputs the full name of the main class. If the process is executing a jar package, the output jar path

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

5. Parameters VL Together: So that we can easily see the parameters set by each program

Jstat

Java statisstic Monitoring tool: A very strong monitoring VM memory utility. can be used to monitor the size of various heap and non-heap sizes and their memory usage in VM memory

1. Usage

Jstat [Options] vmid [interval] [count]

Options, option, we generally use-gcutil to view GC conditions
The VMID,VM process number, which is the currently running Java process number
Interval, interval, units of seconds or milliseconds
Count, number of prints, print countless times if default

2. Parameter list

Jstat-classPID: Displays the number of loaded classes, as well as the occupied space and other information. Jstat-compiler PID: Displays information such as the number of real-time VMS compiled. Jstat-GC PID: can display GC information, view GC number of times, and time.      The last five items were the number of young GC, the time of young GC, the number of full GC, the time of full GC, and the total time of GC. Jstat-gccapacity: It can be shown that the use and occupancy of three generation (Young,old,perm) objects in VM memory, such as: PGCMN shows the minimum perm memory usage, PGCMX shows the maximum amount of memory used for Perm, The PGC is the current newly generated perm memory footprint, and the PC is but the pre-perm memory footprint.      The other can be based on this analogy, OC is the old inside the pure consumption. Jstat-gcnew The information for the Pid:new object. Jstat-gcnewcapacity The information of the Pid:new object and its consumption. Jstat-Gcold The information for the Pid:old object. Jstat-gcoldcapacity The information of the Pid:old object and its consumption. Jstat-gcpermcapacity The information of the Pid:perm object and its consumption. Jstat-Util PID: Statistical GC information statistics. Jstat-printcompilation PID: Information for the current VM execution. In addition to one of the above parameters, you can also add two numbers, such as: Jstat-printcompilation3024  -6 is printed every 250 milliseconds, printing a total of 6 times, you can also add-h3 every three lines to display the title.

3. Practical examples

1.-GC: monitoring Java heap Status

S0C: Capacity of the first Survivor (Survivor area) in the Young Generation (bytes)          s1c: The capacity of the second survivor (survivor) in the Young Generation (bytes)          s0u: The first survivor in the young generation (survivor area) currently used space (bytes)          s1u: The second survivor (Survivor area) of the young generation has currently used space (bytes)          EC: The capacity of the young generation in Eden (bytes)          EU: Eden of the young generation currently used space (bytes) oc:old generation Capacity (bytes)          The capacity of Ou:old (bytes)          pc:perm (persistent generation) is currently used ( bytes)          pu:perm (persistent generation) currently used space (bytes)          

2.-gcutil: Basically the same as-GC, but the output is the size of the total space occupied by the used space

Jinfo

Configuration Info for Java: View and adjust virtual machine parameters in real time

1. Usage:

jinfo [option] <pid>

2. Parameters:

Jinfo is mainly the flag parameter, has been explained very clearly, here directly to do the demonstration good

3. Practical examples

1. Get the Survivorratio information for process 30018

2. Get all the JVM information for process 30018

This command is more detailed than jps-v.

Jmap

-histo PID. If you use the shelljmap-histo pid>-dump:format=b,file=outfile 3024 can output the memory heap of the 3024 process to the outfile file, With the mat (Memory analysis tool) or with the Jhat (Java Heap analytical tools), you can visually display current memory problems in the form of an image. 

1. Usage

jmap [option] <pid>

2. Parameters

1), options:executable Java executable fromwhich the core dump was produced. (possibly a Java executable that produces core dump) core will be printed with the information of the core dump file remote-hostname-or-host name or ipserver of IP Remote Debug service-ID Unique ID, if multiple Remote debug services on a single host2), basic parameters:-dump:[live,]format=b,file=<filename> uses the Hprof binary form to output the contents of the JVM's heap to a file =The . Live sub-option is optional, and if you specify the live option, only the live object is exported to the file.-Finalizerinfo Prints information about objects that are waiting to be reclaimed.-The heap prints a summary of the heap, the algorithm used by the GC, the configuration of the heap, and the use of the wise heap.-histo[:live] Prints the number of instances per class, memory consumption, class full name information. The internal class name of the VM is prefixed with the prefix "*". If the live child parameter is added, only the number of live objects is counted. -Permstat Prints the classload and JVM heap for a long layer of information. Contains the name, liveliness, address, parent ClassLoader, and number of classes loaded for each classloader. In addition, The number of internal strings and the amount of memory consumed are also printed. -F coercion. Use-dump when PID is not appropriate or-The histo parameter. In this mode, the live sub-argument is invalid.-H | -Help Printing auxiliary information-J Pass parameters to the JVM that Jmap started. The Java process ID that the PID needs to be printed with the phase information

3. Practical examples

1.jmap-heap prints the summary of the heap, the algorithm used by the GC, the configuration of the heap, and the use of the wise heap.

This command is very intuitive to show the existence of the various areas of the JVM, online repayment of memory anomalies can be used to do a general understanding of this command

2.jmap-histo:

This command will call out all classes and sort them by the size of the memory consumed.

3.jmap-dump:

Explanation under Jmap-f-dump:format=b,file=payment.bin 30018: Using the Hprof binary form, the output process is 30018 of the JVM's heap content to the file Payment.bin

Jhat

is a command for parsing the Java heap that can display objects in the heap as HTML, including the number of objects, size, and so on, and supports object query language

Now we're going to analyze the payment.bin from the above.

With a browser access to Http://localhost:7000/, you will find all classes categorized by package name, we can access the bottom of this tag, see the content and Jmap-histo: is the same

Reference

Http://www.cnblogs.com/ggjucheng/archive/2013/04/16/3024986.html

http://blog.csdn.net/zlzlei/article/details/46471627

Java Virtual Machine monitoring commands

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.