Day9-JDK性能监控工具:jstat(下)

延续着上篇内容,这篇要来介绍的是jstat中的option有哪些参数可以使用

jstat -<option> [-t] [-h<lines>] <vmid> [<interval>[<count>]]

options介绍

jstat中可使用的参数,可以分为三大类,Oracle官网文件其实并没有分类,但我觉得经过分类,对我来说,会比较容易记忆。

  1. 类加载相关

  • -class

  1. 垃圾回收相关

  • -gc

  • -gccapacity

  • -gcutil

  • -gccause

  • -gcnew

  • -gcnewcapacity

  • -gcold

  • -gcoldcapacity

  • -gcpermcapacity

  1. JIT相关(Just In Time,即时编译)

  • -compiler

  • -printcompilation


以下为示范内容

Step.1准备一个JstatTwoTest.java档案,程序码如下:

package Controller;

import java.util.ArrayList;

public class JstatTwoTest{

  public static void main(String[] args) throws InterruptedException{
    Thread.sleep(15000);
    ArrayList<String[]> list = new ArrayList<>();
    for(int count = 0;count<9;count++) {
	    for(int x = 0;x<1001;x++){
	    	String[] arr = new String[512*x];
	    	list.add(arr);
	    	Thread.sleep(100);
	     }
	    System.gc();
	    System.out.print("rest");
	    Thread.sleep(10000);
    }
  }
}

Step2.将程序码进行编译并且执行

编译与执行的指令说明,请参考Day4-java语言编译器:javac & 运行工具:java (上)

Step3.要进行查看jstat前,须先知道要查看哪个HotSpot进程

透过jps查看,请参考Day7-JDK查看正在运行的Java进程工具:jps

Step4.jstat指令应用

  1. 类加载相关

  • -class:显示与类加载有关行为的统计数据

https://ithelp.ithome.com.tw/upload/images/20210924/20140481NLuynH4T0K.png

  1. 垃圾回收相关

  • -gc:显示有关垃圾回收行为的统计数据

https://ithelp.ithome.com.tw/upload/images/20210924/201404818lmgfFguzq.png

  • -gccapacity

https://ithelp.ithome.com.tw/upload/images/20210924/20140481BR7k5eJI60.png

  • -gcutil

https://ithelp.ithome.com.tw/upload/images/20210924/20140481IYrcIyMpDp.png

  • -gccause

https://ithelp.ithome.com.tw/upload/images/20210924/20140481C0JKTe8MHR.png

  • -gcnew

https://ithelp.ithome.com.tw/upload/images/20210924/20140481WXHTGV6svK.png

  • -gcnewcapacity

https://ithelp.ithome.com.tw/upload/images/20210924/20140481mtNEwTHfSR.png

  • -gcold

https://ithelp.ithome.com.tw/upload/images/20210924/2014048127Wz6q4X1D.png

  • -gcoldcapacity

https://ithelp.ithome.com.tw/upload/images/20210924/20140481ZKCD7TmX5H.png

  • -gcmetacapacity

https://ithelp.ithome.com.tw/upload/images/20210924/20140481azz83iLpwC.png

  1. JIT相关(Just In Time,即时编译)

  • -compiler:显示有关JIT编译过的方法、耗时等统计数据

https://ithelp.ithome.com.tw/upload/images/20210924/20140481rH50dqjCmA.png

  • -printcompilation:显示JVM编译方法的统计数据

https://ithelp.ithome.com.tw/upload/images/20210924/20140481tEZa20vCE5.png


<<:  [ Day 09 ] State 是什麽?

>>:  入门魔法 - function 函式

[Day 30] 阿嬷成为网页前端工程师的下一步

阿嬷成为网页前端工程师的下一步 尽管篇幅长短不一,我们在这 30 天当中讨论了怎麽写 HTML 标签...

Day 26: LeetCode Hard+Medium

Day 26: LeetCode Hard+Medium LeetCode 212. Word Se...

D28 - 压测

开始对TiDB进行测试,测试环境如下: 服务 vcpu ram 数量 TIDB/PD 8 20G 3...

透明这回事

前言 透明向来是敏捷强调的,Scrum 更是把透明列为三大支柱之一,今天想跟大家分享一下我对透明的看...

Day29物件导向

物件导向程序设计可以看作一种在程序中包含各种独立而又互相呼叫的物件思想,当我们提到物件导向的时候,它...