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}
相关推荐
带刺的坐椅16 分钟前
轻量级流程编排框架,Solon Flow v3.5.0 发布
java·solon·workflow·flow·solon-flow
yatingliu201937 分钟前
HiveQL | 个人学习笔记
hive·笔记·sql·学习
David爱编程37 分钟前
线程调度策略详解:时间片轮转 vs 优先级机制,面试常考!
java·后端
郭庆汝39 分钟前
CMake概述用法详细笔记
笔记
武当豆豆39 分钟前
C++编程学习(第25天)
开发语言·c++·学习
张人玉41 分钟前
XML 序列化与操作详解笔记
xml·前端·笔记
风和日丽 随波逐流42 分钟前
java17学习笔记-Deprecate the Applet API for Removal
笔记·学习
淮北也生橘121 小时前
Linux的ALSA音频框架学习笔记
linux·笔记·学习
阿冲Runner1 小时前
创建一个生产可用的线程池
java·后端
写bug写bug2 小时前
你真的会用枚举吗
java·后端·设计模式