Memory Monitoring Tool

Source: Internet
Author: User
Tags jconsole

DK comes with VM analysis tools JPS, jstat, jmap, jconsole

I. Overview

Several tools in Sun's JDK are very useful. Adhering to the principle of free and commercial use. The following is a brief introduction to these tools. (Note: all the tools in this article are included in the jdk5.0 or a later version of the tool set. Like javac, you do not need to install them specially ).

I have found the following four tools: Focus on jconsole and jmap.

1. JPs
.: Similar to the PS on UNIX, it is used to display local Java processes. You can view several Java programs running locally and display their process numbers.

2. jstat
..: A Powerful VM memory monitoring tool. It can be used to monitor the size and memory usage of various heap and non-heap volumes in the VM memory.

3. jmap
..: Print out all 'objects' in the memory of a Java Process (using PID) (for example, the generated objects and their quantity ).
4. jconsole
..: A Java GUI monitoring tool that displays various data in tabular form. You can also remotely connect to and monitor remote server VMS.

II. Introduction:

1. JPs: I think many people have used the ps command in Unix systems. This command is mainly used to display the Process status, processes, and IDs of the current system. The same is true for JPS, which is used to display the current Java Process and Its ID. We can use it to check whether several Java processes have been started (because each Java program occupies only one Java Virtual Machine instance), and their process numbers (prepare for the following programs ), you can also use opt to view detailed startup parameters of these processes.
Usage: Run JPs in the current command line (java_home is required. If not, run it in the directory of the program to be modified ).

Unfortunately, the PS is not easy to use in Linux, and the name is not easy to use. However, the jconsole interface of the fourth tool contains the name of the specific jar package.

/Data/jdk1.6.0 _ 06/bin/JPs
6360 Resin
6322 watchdogmanager
JPS 2466



2. jstat: Monitors VM memory usage.
The jstat tool is extremely powerful and has many options. You can view the usage of each part of the heap and the number of loaded classes in detail. You must add the process ID and the selected parameters to view the process. The following describes the meanings of each parameter.
Jstat-class PID: displays the number of loaded classes and the occupied space.
Jstat-compiler PID: displays information such as the number of real-time VM compilations.
Jstat-gc pid: displays GC information, the number of GC times, and the time. The last five items are the young GC count, young GC time, full GC count, full GC time, and total GC time.
Jstat-gccapacity: displays the usage and usage of three generations (young, old, and Perm) objects in the VM memory. For example, pgcen displays the minimum perm memory usage, pgcmx displays the maximum memory usage of perm. PGC is the memory usage of the newly generated perm, while PC is the memory usage of the previous perm. For others, the OC usage is pure in old.
Jstat-gcnew PID: information of the new object.
Jstat-gcnewcapacity PID: information about the new object and its usage.
Jstat-gcold PID: information of the old object.
Jstat-gcoldcapacity PID: information about the old object and its usage.
Jstat-gcpermcapacity PID: information of the perm object and its usage.
Jstat-util PID: Statistics of GC information.
Jstat-printcompilation PID: information about the current VM execution.
In addition to the preceding parameter, you can add two numbers at the same time, for example, jstat-printcompilation 3024 250 6 is printed every 250 milliseconds, a total of 6 times, you can also add-H3 to display the title in each of the three rows.

3. jmapIs a tool that can output all objects in the memory, or even outputs heap in the VM in binary format as text. Use jmap-histo PID. If you use shell jmap-histo pid>. log can save it to the text (which can also be used in Windows). After a period of time, you can use the text comparison tool to compare which objects are collected by GC. Jmap-dump: format = B, file = F1 3024 can output the memory heap of the 3024 process to the F1 file.

4. jconsoleIt is a GUI program written in Java to monitor VMS and monitor remote VMS. It is very easy to use and has powerful functions. Because it is a GUI program, I will not go into details here. If not, refer to Sun's official documentation.
Usage: Run jconsole in the command line. Select the process.

Friendly prompt: in windows, view the process number. Because the task manager does not display the process ID by default, you can add it as follows. CTRL + ALT + DEL open the task manager, select the 'process' tab, click 'view '-> ''Select column''-> Add 'pid '', you can. Of course there are other good options.

Instance:

Jmap-histo: Live $ PID
Jmap-histo $ PID
Jstack-L $ PID


Memory Monitoring Tool

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.