JVM在线分析-解决问题的工具二(jcmd, jdb, jhsdb)

1. jcmd

bash 复制代码
(base) PS C:\Users\zishi> jcmd -h
Usage: jcmd <pid | main class> <command ...|PerfCounter.print|-f file>
   or: jcmd -l
   or: jcmd -h

  command must be a valid jcmd command for the selected jvm.
  Use the command "help" to see which commands are available.
  If the pid is 0, commands will be sent to all Java processes.
  The main class argument will be used to match (either partially
  or fully) the class used to start Java.
  If no options are given, lists Java processes (same as -l).

  PerfCounter.print display the counters exposed by this process
  -f  read and execute commands from the file
  -l  list JVM processes on the local machine
  -? -h --help print this help message

使用方式

bash 复制代码
Usage: jcmd <pid | main class> <command ...|PerfCounter.print|-f file>

PerfCounter.print

bash 复制代码
(base) PS C:\Users\zishi> jcmd 8196 PerfCounter.print
8196:
java.ci.totalTime=423311945
java.cls.loadedClasses=13392
java.cls.sharedLoadedClasses=0
java.cls.sharedUnloadedClasses=0
java.cls.unloadedClasses=0
java.property.java.class.path=".\quality-server.jar"
java.property.java.home="D:\soft\jdk11"

command

bash 复制代码
(base) PS C:\Users\zishi> jcmd 8196 help
8196:
The following commands are available:
Compiler.CodeHeap_Analytics
Compiler.codecache
Compiler.codelist
Compiler.directives_add
Compiler.directives_clear
Compiler.directives_print
Compiler.directives_remove
Compiler.queue
GC.class_histogram
GC.class_stats
GC.finalizer_info
GC.heap_dump
GC.heap_info
GC.run
GC.run_finalization
JFR.check
JFR.configure
JFR.dump
JFR.start
JFR.stop
JVMTI.agent_load
JVMTI.data_dump
ManagementAgent.start
ManagementAgent.start_local
ManagementAgent.status
ManagementAgent.stop
Thread.print
VM.check_commercial_features
VM.class_hierarchy
VM.classloader_stats
VM.classloaders
VM.command_line
VM.dynlibs
VM.flags
VM.info
VM.log
VM.metaspace
VM.native_memory
VM.print_touched_methods
VM.set_flag
VM.stringtable
VM.symboltable
VM.system_properties
VM.systemdictionary
VM.unlock_commercial_features
VM.uptime
VM.version
help

For more information about a specific command use 'help <command>'.
bash 复制代码
(base) PS C:\Users\zishi> jcmd 8196 help help
8196:
help
For more information about a specific command use 'help <command>'. With no argument this will show a list of available commands. 'help all' will show help for all commands.

Impact: Low

Syntax : help [options] [<command name>]

Arguments:
        command name : [optional] The name of the command for which we want help (STRING, no default value)

Options: (options must be specified using the <key> or <key>=<value> syntax)
        -all : [optional] Show help for all commands (BOOLEAN, false)

VM部分

VM.check_commercial_features

VM.class_hierarchy

VM.classloader_stats

VM.classloaders

VM.command_line

VM.dynlibs

VM.flags

VM.info

VM.log

VM.metaspace

VM.native_memory

VM.print_touched_methods

VM.set_flag

VM.stringtable

VM.symboltable

VM.system_properties

VM.systemdictionary

bash 复制代码
(base) PS C:\Users\zishi> jcmd 8196 VM.unlock_commercial_features
8196:
VM.unlock_commercial_features is obsolete as it is no longer required.
bash 复制代码
(base) PS C:\Users\zishi> jcmd 8196 help VM.uptime
8196:
VM.uptime
Print VM uptime.

Impact: Low

Syntax : VM.uptime [options]

Options: (options must be specified using the <key> or <key>=<value> syntax)
        -date : [optional] Add a prefix with current date (BOOLEAN, false)
(base) PS C:\Users\zishi> jcmd 8196 VM.uptime
8196:
1626.351 s
bash 复制代码
(base) PS C:\Users\zishi> jcmd 8196 help VM.version
8196:
VM.version
Print JVM version information.

Impact: Low

Permission: java.util.PropertyPermission(java.vm.version, read)

Syntax: VM.version
(base) PS C:\Users\zishi> jcmd 8196 VM.version
8196:
Java HotSpot(TM) 64-Bit Server VM version 11.0.13+10-LTS-370
JDK 11.0.13
bash 复制代码
(base) PS C:\Users\zishi> jcmd 8196 help VM.systemdictionary
8196:
VM.systemdictionary
Prints the statistics for dictionary hashtable sizes and bucket length

Impact: Medium: Depends on Java content.

Permission: java.lang.management.ManagementPermission(monitor)

Syntax : VM.systemdictionary [options]

Options: (options must be specified using the <key> or <key>=<value> syntax)
        -verbose : [optional] Dump the content of each dictionary entry for all class loaders (BOOLEAN, false)


(base) PS C:\Users\zishi> jcmd 8196 VM.systemdictionary -verbose=false(默认)
(base) PS C:\Users\zishi> jcmd 8196 VM.systemdictionary -verbose=false
8196:
System Dictionary for jdk.internal.reflect.DelegatingClassLoader @4f178791 class loader statistics:
Number of buckets       :         1 =         8 bytes, each 8
Number of entries       :         1 =        24 bytes, each 24
Total footprint         :           =        32 bytes
Average bucket size     :     1.000
Variance of bucket size :     0.000
Std. dev. of bucket size:     0.000
Maximum bucket size     :         1
System Dictionary for jdk.internal.reflect.DelegatingClassLoader @27e91d24 class loader statistics:
Number of buckets       :         1 =         8 bytes, each 8
Number of entries       :         1 =        24 bytes, each 24
Total footprint         :           =        32 bytes
Average bucket size     :     1.000
Variance of bucket size :     0.000
Std. dev. of bucket size:     0.000
Maximum bucket size     :         1

(base) PS C:\Users\zishi> jcmd 8196 VM.systemdictionary -verbose=true
8196:
Dictionary for loader data: 0x0000015c253ac890 for instance a 'jdk/internal/reflect/DelegatingClassLoader'{0x0000000615600000}
Java dictionary (table_size=1, classes=1, resizable=false)
^ indicates that initiating loader is different from defining loader
   0:  jdk.internal.reflect.GeneratedMethodAccessor50, loader data: 0x0000015c253ac890 for instance a 'jdk/internal/reflect/DelegatingClassLoader'{0x0000000615600000}

Dictionary for loader data: 0x0000015c2ec71dc0 for instance a 'jdk/internal/reflect/DelegatingClassLoader'{0x0000000615600100}
Java dictionary (table_size=1, classes=1, resizable=false)
^ indicates that initiating loader is different from defining loader
   0:  jdk.internal.reflect.GeneratedMethodAccessor49, loader data: 0x0000015c2ec71dc0 for instance a 'jdk/internal/reflect/DelegatingClassLoader'{0x0000000615600100}
相关推荐
汇能感知2 分钟前
光谱相机的工作原理
经验分享·笔记·科技·相机
紫罗兰盛开2 分钟前
分布式调度框架学习笔记
笔记·学习
Eiceblue5 分钟前
使用Python获取PDF文本和图片的精确位置
开发语言·python·pdf
汇能感知8 分钟前
光谱相机在农业中的具体应用案例
经验分享·笔记·科技
Q_19284999069 分钟前
基于Spring Boot的个人健康管理系统
java·spring boot·后端
xianwu54314 分钟前
反向代理模块。开发
linux·开发语言·网络·c++·git
xiaocaibao77719 分钟前
Java语言的网络编程
开发语言·后端·golang
地球空间-技术小鱼34 分钟前
YUM(Yellowdog Updater, Modified)和DNF(Dandified YUM)简介
linux·运维·服务器·笔记·学习
木向38 分钟前
leetcode22:括号问题
开发语言·c++·leetcode
comli_cn39 分钟前
使用清华源安装python包
开发语言·python