JDK--tools命令和JVM详解

1、jstack 打印指定进程pid的线程栈信息,生成指定进程的线程快照信息

jstack -help 打印帮助信息

jstack pid 打印指定进程pid的线程信息

选项(option) -F 当进程夯死(hung)的时候 ;jstack pid 会无法响应,这个时候可以使用-F选项,强制生成线程快照信息(thread dump)

-l 打印更多有关locks的详细信息

2、jps

jps -l 展示全包名

C:\Users\love1>jps -l
25584 sun.tools.jps.Jps
22184 Eclipse

jps 展示主程序所在包名

C:\Users\love1>jps
22184 Eclipse
28072 Jps

jps -m 展示main函数的命令行参数

C:\Users\love1>jps -m
2384 Jps -m
22184 Eclipse

jps -v 展示传递给JVM的参数

C:\Users\love1>jps -v
13680 Jps -Dapplication.home=C:\Program Files\Java\jdk1.8.0_333 -Xms8m
22184 Eclipse -Dosgi.requiredJavaVersion=17 -Dosgi.instance.area.default=@user.home/eclipse-workspace -Dosgi.dataAreaRequiresExplicitInit=true -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true -Xms256m -Xmx2048m -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYSTEM

C:\Users\love1>

3、jstst 监控JVM相关信息

jstat -h /–help 帮助

C:\Users\love1>jstat -gc -t 1 -h 3 22184
invalid argument count
Usage: jstat -help|-options
       jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]

Definitions:
  <option>      An option reported by the -options option
  <vmid>        Virtual Machine Identifier. A vmid takes the following form:
                     <lvmid>[@<hostname>[:<port>]]
                Where <lvmid> is the local vm identifier for the target
                Java virtual machine, typically a process id; <hostname> is
                the name of the host running the target Java virtual machine;
                and <port> is the port number for the rmiregistry on the
                target host. See the jvmstat documentation for a more complete
                description of the Virtual Machine Identifier.
  <lines>       Number of samples between header lines.
  <interval>    Sampling interval. The following forms are allowed:
                    <n>["ms"|"s"]
                Where <n> is an integer and the suffix specifies the units as
                milliseconds("ms") or seconds("s"). The default units are "ms".
  <count>       Number of samples to take before terminating.
  -J<flag>      Pass <flag> directly to the runtime system

jstat -options 查询jstat有哪些子命令选项

C:\Users\love1>jstat -options
-class
-compiler
-gc
-gccapacity
-gccause
-gcmetacapacity
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
-gcutil
-printcompilation

jvm相关参数详细介绍
S0C年轻代中第一个survivor(幸存区)的容量 (字节)
S1C年轻代中第二个survivor(幸存区)的容量 (字节)
S0U年轻代中第一个survivor(幸存区)目前已使用空间 (字节)
S1U年轻代中第一个survivor(幸存区)目前已使用空间 (字节)
EC年轻代中Eden(伊甸园)的容量 (字节)
EU年轻代中Eden(伊甸园)目前已使用空间 (字节)
NGCMN年轻代(young)中初始化(最小)的大小(字节)
NGCMX年轻代(young)的最大容量 (字节)
NGC年轻代(young)中当前的容量 (字节)
jvm相关参数详细介绍
OCOld代的容量 (字节)
OUOld代目前已使用空间 (字节)
OGCMNold代中初始化(最小)的大小 (字节)
OGCMXold代的最大容量(字节)
OGCold代当前新生成的容量 (字节)
jvm相关参数详细介绍
PCPerm(持久代)的容量 (字节)
PUPerm(持久代)目前已使用空间 (字节)
PGCMNperm代中初始化(最小)的大小 (字节)
PGCMXperm代的最大容量 (字节)
PGCperm代当前新生成的容量 (字节)
jvm相关参数详细介绍
YGC从应用程序启动到采样时年轻代中gc次数
YGCT从应用程序启动到采样时年轻代中gc所用时间(s)
FGC从应用程序启动到采样时old代(全gc)gc次数
GCT从应用程序启动到采样时gc用的总时间(s)

其中Eden区是新对象被分配内存的区域,在一次minor GC之后会将Eden区仍存活的对象移动到S0和S1区,未被引用的会被删除;一次GC 会将Eden区仍存活的移动到S0,二次GC会将Eden区和S0区仍存活的移动到S1,三次GC会将Eden区和S1区仍存活的移动到S0,四次GC会将Eden区和S0区仍存活的移动到S1;依次循环,S0和S1交替使用,当对象的存活次数达到某个阈值时,会将该对象移动到Old代。

jstat -gc -t pid 显示时间戳 Timestamp (从进程启动到现在的时间 (s))

C:\Users\love1>jstat -gc -t 22184
Timestamp S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
32604.0 0.0 1024.0 0.0 889.2 312320.0 79872.0 210944.0 145047.5 110208.0 107806.9 13760.0 12711.3 12 0.079 0 0.000 0.079

jstat -gc pid 1s ( ) 等距时间抽样(Sampling interval)即每过1s更新gc信息

jstat -gc pid interval lines ; interval 指定等距时间抽样时间(m/ms),lines指定抽样的数量

jstat -gc pid 1s 10 即每次样本时间间隔为1s,总共打印出10行

C:\Users\love1>jstat -gc   22184  1s 10
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079

C:\Users\love1>

jstat -gc -h 2 pid interval lines ; -h 指定每次样本的数量, interval 指定等距时间抽样时间(m/ms),lines指定抽样的数量

C:\Users\love1>jstat -gc  -h 2 22184  1s 9
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT
 0.0   1024.0  0.0   889.2  312320.0 80896.0   210944.0   145047.5  110208.0 107806.9 13760.0 12711.3     12    0.079   0      0.000    0.079

C:\Users\love1>
  • 14
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值