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}
相关推荐
paopaokaka_luck2 分钟前
基于Spring Boot+Vue的吉他社团系统设计和实现(协同过滤算法)
java·vue.js·spring boot·后端·spring
Flobby52937 分钟前
Go语言新手村:轻松理解变量、常量和枚举用法
开发语言·后端·golang
悠哉悠哉愿意1 小时前
【电赛学习笔记】MaixCAM 的OCR图片文字识别
笔记·python·嵌入式硬件·学习·视觉检测·ocr
nbsaas-boot2 小时前
SQL Server 窗口函数全指南(函数用法与场景)
开发语言·数据库·python·sql·sql server
东方佑2 小时前
递归推理树(RR-Tree)系统:构建认知推理的骨架结构
开发语言·r语言·r-tree
Warren982 小时前
Java Stream流的使用
java·开发语言·windows·spring boot·后端·python·硬件工程
伍哥的传说2 小时前
Radash.js 现代化JavaScript实用工具库详解 – 轻量级Lodash替代方案
开发语言·javascript·ecmascript·tree-shaking·radash.js·debounce·throttle
_Kayo_3 小时前
VUE2 学习笔记5 动态绑定class、条件渲染、列表过滤与排序
笔记·学习
xidianhuihui3 小时前
go install报错: should be v0 or v1, not v2问题解决
开发语言·后端·golang
架构师沉默3 小时前
Java优雅使用Spring Boot+MQTT推送与订阅
java·开发语言·spring boot