Java GC Series (4): Garbage collection Monitoring and analysis

Source: Internet
Author: User
Tags visualvm java se

In this Java GC Series tutorial, let's learn about tools for garbage collection monitoring and analysis. Then, choose a tool to monitor the garbage collection process for a Java sample program. If you are a beginner, you'd better read this series of tutorials carefully. You can start here (garbage collection Introduction).

Java GC Monitoring and analysis tools

Here are some of the tools available, each with its own strengths and weaknesses. We can improve the performance of our applications by selecting the right tools and analyzing them. In this tutorial, we use Java VisualVM.

    • Java VisualVM
    • Naarad
    • Gcviewer
    • IBM Pattern Modeling and Analysis Tool for Java garbage Collector
    • Hpjmeter
    • IBM monitoring and Diagnostic Tools for Java-garbage Collection and Memory
    • Visualizer
    • Verbose GC Analyzer
Java VisualVM

Java VISUALVM is free to use and requires the Java SE SDK to be installed. Take a look at the Java JDK in the Bin folder (path: \java\jdk1.8.0\bin), which has a lot of javac and Java tools, JVISUALVM is one of them.

Java VISUALVM can be used to:

    • Generate and analyze memory dumps for the heap;
    • Observe and operate on the Mbeans;
    • Monitor garbage collection;
    • Memory and CPU performance analysis;
1. Start VisualVM

JVISUALVM is located in the JDK Bin folder and can be clicked directly.

2. Installation Visualization GC Plugins

We need to install a visual GC plug-in so that we have a good visual sense of the Java GC process.

3. Monitoring GC

Now, it is time to monitor the garbage collection process, open your Java program, it will automatically be detected and displayed to the Java VISUALVM interface, the left "application" (application) window, "local" (native node), All locally run Java programs will be listed.

Java VISUALVM is a Java application, so it is also listed, and the tutorial is intended to use VISUALVM to monitor its own GC process.

Double-click the VISUALVM icon under Local.

Now, the Program Monitoring window opens on the right, which has many different tab pages about the monitoring index of the application's performance, so far, we are most interested in "Visual GC", click on it.

The above picture shows the space utilization on old, Eden, S0, and S1, showing the distribution and release of each part of the space. It maintains a continuous refresh at the specified refresh rate.

The picture above shows the normal running program, which is clearly displayed in the chart when there is a memory leak or abnormal behavior. At least we can understand that he is related to object memory allocation and garbage collection. Then, with the help of Other tab pages (like "Threads") and thread dump, we can reduce the problem.

In the Monitor tab, we are able to monitor and periodically display all heap memory usage graphs. The Perform GC button enables you to start the garbage collection process.

In the "Sampler" tab page, we are able to start memory and CPU profiling, which will show detailed real-time reports used by each instance, which will help us identify performance issues.

Java GC Series (4): Garbage collection Monitoring and analysis

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.