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}
相关推荐
大春儿的试验田37 分钟前
Parameter ‘XXX‘ not found. Available parameters are [list, param1]
java
我很好我还能学1 小时前
【面试篇 9】c++生成可执行文件的四个步骤、悬挂指针、define和const区别、c++定义和声明、将引用作为返回值的好处、类的四个缺省函数
开发语言·c++
程序员JerrySUN1 小时前
[特殊字符] 深入理解 Linux 内核进程管理:架构、核心函数与调度机制
java·linux·架构
2302_809798321 小时前
【JavaWeb】Docker项目部署
java·运维·后端·青少年编程·docker·容器
蓝婷儿1 小时前
6个月Python学习计划 Day 16 - 面向对象编程(OOP)基础
开发语言·python·学习
渣渣盟2 小时前
基于Scala实现Flink的三种基本时间窗口操作
开发语言·flink·scala
网安INF2 小时前
CVE-2020-17519源码分析与漏洞复现(Flink 任意文件读取)
java·web安全·网络安全·flink·漏洞
一叶知秋哈2 小时前
Java应用Flink CDC监听MySQL数据变动内容输出到控制台
java·mysql·flink
jackson凌2 小时前
【Java学习笔记】SringBuffer类(重点)
java·笔记·学习
sclibingqing2 小时前
SpringBoot项目接口集中测试方法及实现
java·spring boot·后端