JVM Performance Tuning monitoring Tools JPS, Jstat, Jinfo, Jmap, Jhat, Jstack use detailed

Source: Internet
Author: User
Tags visualvm

In addition to the integrated VISUALVM and Jconsole, the JDK itself provides performance tuning monitoring tools such as JPS, Jstack, Jmap, Jhat, and Jstat.

In Java development, we sometimes encounter the following problems:

OutOfMemoryError, Low memory

Memory leaks

Thread deadlock

Lock contention (lock contention)

The Java process consumes too much CPU

......

These problems may be overlooked by many people in their daily development (for example, some people encounter the problem just to restart the server or to increase memory, but not to delve into the root cause of the problem), but to understand and solve these problems is the Java Programmer advanced requirements. This article refers to a lot of information on the Internet, some common JVM performance tuning monitoring tools are introduced.

1.JPS: Used primarily to output process state information running in the JVM. The syntax format is as follows:

jps[options][hostid]

If you do not specify HostID, the current host or server is assumed to be the default.

The command line parameter options are described below:

-q 不输出类名、Jar名和传入main方法的参数-m 输出传入main方法的参数-l 输出main类或Jar的全限名-v 输出传入JVM的参数

such as the following:

The 2.JSTAT:JVM Statistical Monitoring tool, a tool that can be used to observe Java Application Runtime information, is very powerful and allows you to view the details of the heap information. The syntax format is as follows:

jstat[generalOption | outputOptions vmid [interval[s|ms][count]]]

The command line parameter options are described below:

-class 显示加载class的数量及所占空间等信息。-compiler 显示VM实时编译的数量等信息-gc 可以显示gc的信息,查看gc的次数,及时间 -gccapacity 可以显示,VM内存中三代(young,old,perm)对象的使用和占用大小-gccause 最近一次GC统计和原因 -gcnew 年轻代对象的信息-gcnewcapacity 年轻代对象的信息及其占用量-gcold old代对象的信息-gcoldcapacity old代对象的信息及其占用量-gcpermcapacity perm对象的信息及其占用量-gcutil 统计gc信息-printcompilation HotSpot 当前VM执行的信息

Examples are as follows:

3.jinfo: Can be used to view the extension parameters of a running Java application, and even modify some parameters at run time, its basic syntax is:

optionoptionoption ] [server[email protected]]remote-hostname-or

The command line parameter options are described below:

no option  打印命令行参数和系统属性-flags  打印命令行参数-sysprops  打印系统属性

Examples are as follows:

4.jmap: Mainly used to generate heap snapshot files, the syntax format is as follows:

jmap [option] pidjmap [option] executable corejmap [option] [server[email protected]]remote-hostname-or-ip

The command line line parameter options are described below:

- Dump:[live,]format=b,file=<filename> uses hprof binary form, output JVM's heap content to File =. Live sub-option is optional, if you specify the live option, Then 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 theGC , 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 "*". If the live child parameter is added, only the number of live objects is counted. -Permstat Prints information about the classload and JVM heap for a long time. Contains the name of each classloader, the liveliness, the address, the parent ClassLoader, and the number of classes loaded   . In addition, the internal The number of strings and the amount of memory consumed will also be printed. - F coercion. Use the-dump or-histo parameters when the PID is not appropriate. In this mode, the live sub-argument is not valid.- J Pass parameters to the JVM that Jmap started.

Examples are as follows:

After obtaining the heap snapshot file, we can use a variety of tools to analyze the file, such as JHAT,VISUALVM.

5.jhat: You can parse a Java application's heap snapshot file in the following syntax format:

Jhat after the analysis is complete, use the HTTP server to show the results of the analysis, and access the http://127.0.0.1:7000/in the browser to get the analysis results.

6.jstack: Used primarily to view thread stack information within a Java process. The syntax format is as follows:

jstack [option] pidjstack [option] executable corejstack [option] [server[email protected]]remote-hostname-or-ip

The command line parameter options are described below:

-l long listings,会打印出额外的锁信息,在发生死锁时可以用jstack -l pid来观察锁持有情况-m mixed mode,不仅会输出Java堆栈信息,还会输出C/C++堆栈信息(比如Native方法)

The stack information is printed to a file, and you can see whether there is a deadlock in the file.

JVM Performance Tuning monitoring Tools JPS, Jstat, Jinfo, Jmap, Jhat, Jstack use detailed

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.