Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of JVM monitoring tools?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

I believe that many inexperienced people don't know what to do about the usage of JVM monitoring tools. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

If you know anything about the use of JVM monitoring tools, here are a few. VisualVM is a visualization tool that integrates multiple JDK command-line tools, which can provide you with powerful analytical capabilities. All of these are free!

Introduction of JVM monitoring tools

VisualVM is a visualization tool that integrates multiple JDK command-line tools that provide you with powerful analytical capabilities. All of these are free! The command-line tools it includes include jps,jstat,jmap,jinfo,jstack,JConsole, which are consistent with the standard version of JDK.

Jps: similar to ps on unix, it is used to display local java processes. You can see how many java programs are running locally and show their process numbers.

Jstat: a powerful tool for monitoring VM memory. Can be used to monitor the various heap and non-heap sizes in VM memory and their memory usage.

Jmap: print out all the 'objects' in the memory of a java process (using pid) (e.g. those objects and their number).

Jinfo: this JVM monitoring tool can output and modify the opts of a run-time java process.

Jsatck: if the java program crashes to generate a core file, the jstack tool can be used to get information about the javastack and nativestack of the core file, so you can easily know how the java program crashed and where the program went wrong.

Jconsole: a javaGUI monitoring tool that can display a variety of data in a graphical form. And you can monitor the remote server VM through a remote connection.

The following is a detailed description of these JVM monitoring tools:

◆ starts with the simplest jps tool: I think a lot of people have used the ps command in the unix system, which is mainly used to show the current system process, which processes are available, and their id. The same is true of jps, which displays the java process of the current system and its id number. We can use it to see how many java processes we started (because each java program will own an instance of the java virtual machine), and their process numbers (in preparation for the following programs), and we can view the detailed startup parameters of these processes through opt.

How to use: type jps under the current command line (if you need JAVA_HOME, if not, type in the directory of the modified program)

◆ is followed by jstat, and I tuned Liferayportal this time because, by default, liferay generates permoutofmomery exceptions as soon as there are more concurrent users. Although it was solved very quickly, it was found that it was important to monitor VM memory usage. Through google, the tool jstat was quickly discovered.

The jstat tool is particularly powerful with many options to take a closer look at the usage of various parts of the heap, as well as the number of loaded classes. When using it, you need to add the process id of the viewing process, and the selected parameters. The meaning of each parameter is described in detail below.

Jstat-classpid: displays information such as the number of loaded class and the space occupied.

Jstat-compilerpid: displays information such as the number of VM real-time compilations.

Jstat-gcpid: you can display gc information, the number of times to view the gc, and the time. Five of them are the number of younggc, the time of younggc, the number of fullgc, the time of fullgc, and the total time of gc.

Jstat-gccapacity: you can show the usage and usage of young,old,perm objects in VM memory. For example, PGCMN shows the minimum memory usage of perm, PGCMX shows the memory usage of perm, PGC is the current newly generated perm memory usage, and PC is the previous perm memory usage. According to this analogy, OC is the pure occupancy within old.

Information about the jstat-gcnewpid:new object.

The information about the jstat-gcnewcapacitypid:new object and its usage.

Information about the jstat-gcoldpid:old object.

The information about the jstat-gcoldcapacitypid:old object and its usage.

The information about the jstat-gcpermcapacitypid:perm object and its usage.

Jstat-gcutilpid: statistics gc information statistics.

Jstat-printcompilationpid: the information currently executed by VM.

In addition to the above parameter, you can also add two numbers at the same time, such as: jstat-printcompilation30242506 prints every 250ms, a total of six times, and you can add-h4 to display the title every three lines.

◆ jmap is a tool that can output all objects in memory, and you can even output heap in VM into text in binary. Use the method jmap-histopid. If you use SHELLjmap-histopid > a.log to save it to text, after a period of time, using the text comparison tool, you can compare which objects have been recycled by GC. Jmap-dump:format=b,file=String3024 can output the memory heap of 3024 processes to a String file.

◆ jinfo: this JVM monitoring tool is relatively simple to use, that is, it can output and modify the running parameters of the java process at runtime. The usage is jinfo-optpid such as: to see the MaxPerm size of 2788, you can use jinfo-flagMaxPermSize2788.

◆ jsatck: you can observe the current operation and current state of all threads in the jvm

Jstack2083

◆ jconsole is a GUI program written in java, which is used to monitor VM and remote VM. It is very easy to use and very powerful. Since it is a GUI program, I will not introduce it in detail here. If not, you can refer to the official documentation of SUN.

How to use it: type jconsole on the command line and select the process.

After reading the above, have you mastered the usage of JVM monitoring tools? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report