官术网_书友最值得收藏!

Monitoring garbage collection with jstat

jstat is a JVM command-line tool, which shows you a number of statistics regarding how the JVM is performing. In this recipe, we use jstat to understand the size of the permanent generation.

Getting ready

You will need the SOA Suite installed for this recipe, and will need permission to execute the domain control scripts, as well as the JVM tools. This recipe assumes that your SOA Suite application is running under a normal load.

The tools jps and jstat are included with both the HotSpot and JRockit JVMs. For brevity, this recipe assumes that you have the relevant bin directory on your path. If you do not, simply use the fully qualified paths to the relevant bin directory.

This recipe assumes you are using HotSpot, as JRockit does not have a permanent generation.

How to do it…

  1. Use JPS to determine the process ID of your SOA Suite server, see step 1 of the Identifying New Size Problems with jstat recipe.
  2. Use the jstat command to view the sizes of the survivor spaces and eden:
    jstat -gc -h10 <pid> 2000

    The metrics we are interested in are YGCC, YGCT, FGCC, and FGCT. These are the young garbage collection count, young garbage collection time, full garbage collection count, and full garbage collection time.

How it works…

jstat is a JVM tool that can be used to view a number of runtime statistics regarding the JVM. The option –gc prints statistics about garbage collection, including the capacity and utilization of each memory pool. In the preceding example, the parameter –h10 prints the headers every 10 lines, to make the output easier to read, and 2000 is the time in milliseconds between each sample (2 seconds).

Since garbage collection is a "stop the world" activity, any time spent garbage collecting is not the time spent in executing your business logic. We therefore want to minimize the amount of time spent in performing garbage collection. See the chapter on garbage collection for more details on what we are looking to achieve with garbage collection tuning.

There's more…

In Chapter 5, JVM Garbage Collection Tuning, we also pass the JVM a startup option to enable verbose GC logging output, so we can capture this data all the time.

We can then run free tools such as GCviewer (http://www.tagtraum.com/gcviewer.html) on this data output to visualize the data trends. Later in this chapter, we will introduce using real-time monitoring tools bundled with the JVM to view this same data.

See also

  • The Identifying performance problems using VisualVM on HotSpot and Identifying performance problems with jrmc on JRockit recipes
  • The Tuning to reduce the number of major garbage collections and Turning on verbose garbage collection recipes in Chapter 5, JVM Garbage Collection Tuning
主站蜘蛛池模板: 含山县| 天柱县| 涟水县| 芜湖市| 新泰市| 虹口区| 朝阳区| 东安县| 泗水县| 关岭| 庆云县| 康保县| 深水埗区| 曲松县| 浮梁县| 麻栗坡县| 石首市| 松原市| 彭山县| 马龙县| 资阳市| 尉氏县| 莎车县| 筠连县| 顺昌县| 安义县| 云和县| 洪洞县| 徐州市| 壤塘县| 合阳县| 汉川市| 泰来县| 宜章县| 翁源县| 山阳县| 纳雍县| 巴林右旗| 泾源县| 阳信县| 淄博市|