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

How to realize the usage of JVM memory Monitoring tool

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

Share

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

This article shows you how to achieve JVM memory monitoring tool usage, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.

Are you familiar with the use of JVM memory monitoring tools? here is a brief introduction. VisualVM includes command-line tools including jps,jstat,jmap,jinfo,jstack,JConsole, which are consistent with the standard version of JDK, which can provide you with strong analysis capabilities to achieve JVM memory monitoring.

A complete Collection of JVM memory 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.

Jinfo: you can output and modify the opts of the java process at run time.

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).

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.

Next is a detailed description of these JVM memory monitoring tools:

◆ starts with the simplest jstat 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)

Next is jstat, and I tuned Liferayportal this time because by default, liferay generates permoutofmomery exceptions when there are more than one concurrent user. 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-utilpid: 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 JVM memory monitoring tool that can output all objects in memory, and 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 memory monitoring tool is relatively simple to use, which is to output and modify the running parameters of the java process at run time. The usage is jinfo-optpid such as: to see the MaxPerm size of 2788, you can use jinfo-flagMaxPermSize2788.

◆ 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.

Usage: type jconsole on the command line and select the process.

The above is how to implement the usage of JVM memory monitoring tools. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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