Java program Profiling Tools Java VisualVM (Visual GC)-A must-have tool for programmers

Source: Internet
Author: User
Tags visualvm

VisualVM is a free, integrated visualization tool with multiple JDK command-line tools that provides you with powerful analytics and performance analysis and tuning of your Java applications. These features include generating and analyzing massive amounts of data, tracking memory leaks, monitoring the garbage collector, performing memory and CPU analysis, and it also supports browsing and manipulation on MBeans.

In memory analysis, the biggest benefit of Java VISUALVM is that you can analyze GC (gabage Collection) trends and memory consumption details by installing a visual GC plug-in.

A Visual GC (monitor garbage collector)

Java VisualVM Default does not install the Visual GC plug-in, requires manual installation ,the JDK installation directory of the bin mesh double-click jvisualvm.exe, you can open the Java VisualVM, click the menu bar tools, plug-in installation visual GC

Restart Java visualvm,visual GC interface automatically opens to see the generation of heap memory in the JVM after installation is complete

After the monitored program has been running for some time, the visual GC displays the following

To understand the diagram above, some basic concepts of the Java Virtual machine must be understood:

Heap : JVM-managed memory called Heap


Generational: According to the life cycle length of the object, the heap is divided into 3 generations:Young,old and permanent, according to the characteristics of different generations to adopt different collection algorithms, weaknesses are also.

    1. Young (younger generation)
      The young generation is divided into three districts. One Eden area, two survivor districts. Most objects are generated in the Eden area. When the Eden Zone is full, the surviving objects will be copied to the Survivor area (one of two), and when the survivor area is full, the surviving objects of this area will be copied to another survivor area, when the survivor is full, Objects that are copied from the first survivor area and that are still alive will be duplicated in the old Age zone (tenured). It is important to note that the two districts of survivor are symmetrical and have no relationship, so the same district may have objects copied from Eden, and objects copied from the previous survivor, and copied to the old quarter only from the first survivor. Moreover, there is always an empty survivor area.

    2. Tenured (old generation)
      Older generations store objects that survive from younger generations. In general, older generations are storing long-term objects.

    3. Perm (persistent generation)
      Used to store static files, now Java classes, methods, and so on. The persistence generation has no significant impact on garbage collection, but some applications may dynamically generate or invoke some classes, such as Hibernate, at which point a large, persistent generation space is required to store the new class in these runs. The persistent generation size is set by-xx:maxpermsize=.

Basic concepts of GC

GC is divided into full GC and minor GC, which will cause GC when each chunk is filled.

    1. Scavenge GC
      In general, when a new object is generated and the Eden application space fails, the scavenge GC is triggered, the heap Eden Zone is GC, the non-surviving objects are cleared, and the surviving objects are moved to the survivor area. Then tidy up the two districts of survivor.

    2. Full GC
      Organize the entire heap, including young, tenured and perm. The full GC is slower than the scavenge GC, so the full GC should be minimized as much as possible. The full GC may be caused by the following reasons:

    • Dynamic changes in the domain allocation policy of the heap after the last GC

    • System.GC () is displayed call

    • Perm field is full

    • Tenured was written full

memory overflow out of memory, refers to the program in the application of the RAM, there is not enough memory space for its use, there is an out-of-memory; for example, an integer is applied, but a long can be stored to save it.

memory leak memories leak, refers to the program after the application of memory, can not release the requested memory space, a memory leak damage may be ignored, but the memory leak accumulation of serious consequences, no matter how much memory, sooner or later will be occupied. In fact, it is not recycled after the memory space has been used.

Other features of the two Java VISUALVM

1. Monitoring interface (CPU, class, heap, thread)

2. Threading Interface

3.Profile Interface (profiling)

Click the CPU button to perform the CPU analysis view method

Click the memory button to perform a memory analysis view class

4. Heap dump and thread dump operations

dump file is the memory image of the process, you can save the execution state of the program through the debugger to the dump file, heap dump dump file content as shown

Java program Profiling Tools Java VisualVM (Visual GC)-A must-have tool for programmers

Related Article

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.