JVM Performance Tuning Monitoring Tool Topic 3: Snapshot Analysis, Monitoring GC, and Eclipse Integration of VisualVM Basics

I. Overview

The last topic specifically illustrates the use of VisualVM for remote monitoring and remote monitoring of Tomcat. If you are interested, you can view:

http://josh-persistence.iteye.com/blog/2233459

This topic will explain how to use VisualVM to generate snapshots, how to monitor the GC of the JVM, and finally give an example of how to integrate VisualVM and eclipse.

 

2. Snapshot function

We can use the snapshot function of VisualVM to generate any number of performance analysis snapshots and save them locally to assist us in performance analysis. Snapshots provide a convenient way to capture application profiling data because once generated, snapshots can be opened and viewed offline at any time, as well as shared with each other. VisualVM provides two types of snapshots: Profiler snapshots and application snapshots.

 

  • Profiler snapshot: When a performance analysis session (memory or CPU) is in progress, we can generate a Profiler snapshot to capture the current performance analysis data through the "Snapshot" button in the performance analysis result toolbar.



 After clicking the "Snapshot" button, a Profiler snapshot is generated, or you can choose to store the snapshot locally:



 

  • Application snapshot: We can right-click on the application node in the Applications window on the left and select "Application Snapshot" to generate an application snapshot. The application snapshot will collect heap dumps, thread dumps and Profiler snapshots at a certain moment, and also capture some basic information of the JVM.

 

 



 

After the snapshot is saved, the application can be analyzed offline according to the offline mode.

 

3. Monitor JVM GC

If you need to use VisualVM to monitor GC, first we need to install the visual GC plugin, click Tools->Plugins->Available Plugins->Visual GC in the startup interface above



 

After the installation is complete, you can start monitoring the GC. Run the HeapMemoryTest.java mentioned in the first lecture, and you can get the following screenshot:




The left side of the above figure shows the memory space used by Old, Eden, S0, S1. The chart on the right shows the details of allocating and freeing memory for each part. It keeps updating at the set refresh rate.

 

上图显示的是一个正常运行的程序。当发生内存泄露或者不正常的操作时,可以从图形本身明显地看出来,至少我们可以知道程序中存在和对象内存分配 和垃圾回收相关的问题。然后利用其他标签如“Threads”中提供的信息和Thread Dump我们可以缩小发生问题的范围。如下图:



 

在“监视”标签中,我们可以看到以时间线发展的内存使用概况图。这里有个“执行垃圾回收”按钮可以调用垃圾回收过程。

 

四、与Eclipse集成

其实我并不介意将eclipse和virsualvm集成起来,这不仅会加重eclipse的负担,在eclipse中的virsualvm标签和eclipse的程序代码标签之间切换来切换去会比较麻烦,还不如像前面所提到的一样,直接在控制台中启动visualvm,这样当eclipse中的程序启动的时候,就会默认被visualvm所监控到,这样不仅减轻了eclipse的负担,在问题发生时,也可以很好的对照eclipse中的代码和visualvm中的状态。

 

但是如果你确实很想在eclipse中添加visualvm的插件,首先可以从这里下载最新的eclipse launcher for visual vm: https://visualvm.java.net/eclipse-launcher.html,然后参照如下的两篇博客:

 

http://developer.51cto.com/art/200906/130424_all.htm 

http://www.blogjava.net/Nirvana/archive/2012/09/13/387618.html

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326876123&siteId=291194637