JVM Monitoring Tools Jmap, Jstat, Stacks, JPS, JSTATD, Jinfo, Jhat, Jdb

Source: Internet
Author: User
Tags garbage collection stack trace

1, Jdb (the Java debuger)

JDB is used to debug core files and running Java processes in real-time, with rich commands to help you debug, and its functionality is very similar to the DBX in Sun Studio, but JDB is specifically designed for Java applications.

Now it should be said that the daily development of the jdb is seldom used, because now the IDE has been packaged for us, such as the use of Eclipse Invoke program is very convenient, as long as in very specific circumstances may use this command, such as remote server maintenance, no IDE debugging, Jdb should be able to help at this time.

2. JSTATD (JVM monitoring Tool JSTATD)

JSTATD is an RMI (Remove Method invocation)-based service program that monitors the creation and destruction of resources in a hotspot-based JVM, and provides a remote interface that allows remote monitoring tools to connect to local JVM execution commands.

JSTATD is RMI-based, so the RMI registry must exist on the server running JSTATD, and if you do not specify the port to which you want to connect by using the option "-P port", JSTATD will attempt to connect to the default port of the RMI registry.

Option Function
-nr If the RMI registry is not found, an internal RMI registry is not created
-P Port The port number of the RMI registry, which defaults to 1099
-N Rminame Default is Jstatremotehost
-j Used to pass the JVM option into the Java loader called by Javac

3. Jinfo (JVM configuration Info for Java)

The role of Jinfo is to view the parameters of a virtual machine in real time jps–v can see the parameter information that is explicitly specified by the virtual machine at startup, but what if you want to know the default parameter information? In addition to querying the corresponding data, Jinfo is very important. The usage of Jinfo is as follows:

The parameter options are described below:

Option Function
No option Output command line parameters and System Properties
-Flags Output command Line arguments
-Sysprops Output System Properties

4. JPS (Java Virtual machine Process Status Tool)

JPS is named after the naming rules of the UNIX system, and his functions are similar to that of PS, which can enumerate the running Java Virtual machine processes and display the main classes that the virtual machine executes and the unique IDs of those processes (Lvmid, which corresponds to native PID), and uses the following:

If you do not specify HostID, the default is that the current host or server

The parameter options are described below:

Option Function
-Q Output Lvmid only
-M Outputs the method passed to the main class when the JVM starts
-L Outputs the full name of the main class and, if it is a jar, the path of the output jar
-V Output JVM's startup parameters

5. Jstack (JVM Stack Trace for Java)

Jstack is a thread snapshot for the current time of the JVM, also known as the Threaddump file, which is a collection of stack information that is currently being executed by each thread of the JVM. The primary purpose of generating a thread snapshot is to locate the cause of a thread's long pause, such as thread deadlock, dead loop, and the reason that the thread has stalled due to long external requests. By Jstack, we can know what processes are doing in the background. Waiting for what resources and so on! It runs in the following format:

The relevant option and function are shown in the following table:

Option Function
-F Force the output thread stack when a normal output request does not respond
-L Displays additional information about the lock, in addition to the stack information
-M Displaying stack information for the native method

6. Jstat (JVM Statistics monitoring Tools)

Jstat is mainly used to monitor the virtual machine's various operational state information, such as class loading, memory, garbage collection, JIT compiler, etc., on the server without a GUI, this tool is the preferred monitoring tool. Its usage is as follows:

The parameters interval and count represent the query interval and the number of queries, such as the garbage collection of process 2053 per 2000 milliseconds, monitored 5 times, as shown in the following command:

Options option represents information about the virtual machine that the user needs to query, mainly in 3 categories: Class load, garbage collection, and run-time compilation, as shown in the following table:

Option Function
-class Monitor the load and unload quantities of classes, and the total space and time spent for class loading
-gc Monitor the Java heap, containing information about the capacity, used space, GC time totals, and so on for Eden, 2 survivor zones, old and permanent zones
-gccapcity The monitoring content is the same as-GC, but the output focuses on the maximum and minimum space used in the Java region
-gcutil The monitoring content is the same as-GC, but the output focuses on the percentage of space used for the total space
-gccause Same as-gcutil output information, additional output causes the last GC to occur
-gcnew Monitor the new generation of GC scenarios
-gcnewcapacity As with the-gcnew monitoring information, the output focuses on the maximum and minimum space used
-gcold Monitor GC status for Laosheng generation
-gcoldcapacity As with the-gcold monitoring information, the output focuses on the maximum and minimum space used
-gcpermcapacity Maximum and minimum space for output permanent band
-compiler Output JIT compiler compiled methods, time-consuming information
-printcompilation How the output has been JIT-compiled

7. Jmap (JVM Memory Map for Java)

The jmap is used to generate a heap snapshot (heapdump). Of course, we have a lot of ways to get the corresponding dump information, such as when we start with the JVM to join the start parameter –xx:heapdumponoutofmemoryerror parameter, you can let the JVM in case of memory overflow error when the dump file can be generated, also through the-XX : Heapdumponctrlbreak parameter, use Ctrl+break key to generate dump file at run time, of course we can use kill-3 pid to scare JVM to generate dump file. Jmap's role is not only to obtain a dump file, but also to query the details of the Finalize execution queue, Java heap, and permanent band, such as space usage, garbage collector, and so on. It runs in the following format:

Option information is shown in the following table:

option function
-dump
-finalizerinfo< /td> The object that shows the F-queue method waiting in finalizer (only valid under Linux)
-heap show details of the heap, garbage collector information, parameter configuration, generational details, etc.
-histo display statistics for objects in the stack, including class, number of instances, and total capacity
-permstat
-f This option can be used to force a dump snapshot to be generated when the virtual machine is unresponsive to-dump

8. Jhat (JVM Heap analysis Tool)

Jhat is a miniature http/html server used to analyze the dump file, which generates an online HTML file for the generated dump file, so that we can look it up through the browser, but in practice we seldom use this tool because the heap and stack memory are larger on the general server, Generated dump is also relatively large, directly with jhat easily caused by memory overflow, but most of us will copy the corresponding files, through other visual tools to analyze. The Enable method is as follows:

After executing the command, we see that the system starts to read the dump information, and when the system prompts the server is ready, the user can query by typing http://ip:7000 in the browser, such as:

JVM Monitoring Tools Jmap, Jstat, Stacks, JPS, JSTATD, Jinfo, Jhat, Jdb

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.