VISUALVM Use Experience __JVM

Source: Internet
Author: User
Tags visualvm

There is a handy tool in the JDK "VISUALVM" can be visualized real-time visualization of the Java program memory changes, for understanding GC and Java memory Management is still a great help, before the forum to see the post about Java memory management is really different. Some people say that "the memory of the JVM is divided into two stacks and stacks," and it was said that "the JVM's memory is divided into three (Cenozoic, old age, Method area)", I think a lot of people and I have a bit confused. Here's to see for real:

工欲善其事 its prerequisite, first of all, to VISUALVM install some plug-ins to enable us to observe the memory management of the JVM, 1 visualvm Simple introduction 1.1 Open VISUALVM (This tool is placed in the JDK installation directory in the bin directory, Double-click Jvisualvm.exe to open it, as shown in the following figure

1.2 to VISUALVM itself as an example, VISUALVM itself is a Java program, of course, but also with VISUALVM to analyze 1.3 Overview Page mainly displays program startup parameters and System information (as shown in the following figure)

Øpid-The process number after the program is started and can be viewed using the JPS command at the command line

Ø host-If it is the local words display, localhost, if the remote host should be the display of the remote host name or IP

Ø Main Class--Program entry class (class of Main method)

Ø Parameters--some configuration file paths used when the VISUALVM is started

ØJVM--JVM type

Øjava-Version information for JDK

Øjava Home-JDK installation directory

L JVM Parameters--JVM parameters set at VISUALVM startup

L System Properties--system parameters in the Java Environment 1.4 Monitoring page mainly shows the system resource consumption (as shown in the following figure)

ØCPU--The display of CPU resources when Java programs are running the following illustration shows the percentage of CPU resources that the program runs using, and the blue portion indicates that the garbage collection consumes% of the CPU resources

o Heap--here to illustrate the components of the next heap of memory, the heap is composed of the old and Cenozoic, of which the Cenozoic is composed of "Garden of Eden" and "two surviving regions," the heap view of the resource occupancy is actually "old age", "Eden", "two Survivors (Survivor)" A comprehensive situation.

Øpermgen-the Perm zone is used to store static data for Java classes and other virtual machines (often referred to as persistent generation or method areas).

Ø Class--This view mainly shows how many classes the current program has loaded

Ø Thread--Thread start of current program

§ Perform garbage collection-manually triggering a GC is equivalent to calling (System.GC ()) in program code, and if you are remotely connected to a production environment, click carefully.

§ Heap Dump--the production of the current program's memory snapshot Hprof file is helpful for analyzing memory overflow issues. (You can view all objects in the current program's memory) 1.5 thread page (all threads running state in the main display program)

Ø thread dump– This button mainly produces snapshots of all threads in the current program (for analysis thread deadlock, more helpful)

Ø Timeline – shows the real-time running state of each thread (different colors represent different states)

Ø table – Show time statistics for each thread in different states in the form of a two-dimensional table

Ø Details – Show the running state of each thread in pie chart


1.6 Sampling device (should be considered as a complement to the thread page function)

Cpu-> CPU Sample-the proportion and time of CPU resources consumed by the main presentation method


Cpu-> Thread CPU Time-The main presentation thread consumes CPU resource information


Memory-> Heap Column chart – Number of bytes and total instances of objects in the heap memory


Memory->permgen– show how memory is consumed by various objects in the method area


Memory-> per thread allocation-shows the memory footprint of different threads


1.7 Add VISUALGC plugin 1.7.1 Click Tool-> Plugin, then in the plugin page into the available plugins page, click to check for updates, as shown in the following figure will show all the available Plug-ins


1.7.2 Select VISUALGC and click Install, after the installation is completed, you need to reopen the analysis page to see the VISUALGC page, as shown below

Depending on the information in the VISUALGC, you can adjust the startup parameters of the program so that you don't get your head on when you start the argument (you're actually patting the head when you set up Tomcat's startup parameters in your previous job).

According to the information in this diagram, the area of Eden is significantly too often, increasing the amount of memory in this area to reduce the number of GC times.

For the topic of the opening, it is said that "the memory of the JVM is divided into two stacks and stacks", and it is said that "the JVM's memory is divided into three (Cenozoic, old, method area)".

For the people on the stack, they look at the problem in terms of the dimensions in the image below.


The people who think of the generational argument are based on the dimensions in the following figure.


Can't say who is right or wrong, just look at the dimensions of the problem is different, here should be clear about their relationship

Heap = old+eden+s0+s1 (range in red circle in the following figure)

stack = range in the blue circle in the perm area below

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.