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

1. jcmd

(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

使用方式

Usage: jcmd <pid | main class> <command ...|PerfCounter.print|-f file>

PerfCounter.print

(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

(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 '.
(base) PS C:\Users\zishi> jcmd 8196 help help
8196:
help
For more information about a specific command use 'help '. 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

(base) PS C:\Users\zishi> jcmd 8196 VM.unlock_commercial_features
8196:
VM.unlock_commercial_features is obsolete as it is no longer required.
(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
(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
(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}

你可能感兴趣的:(jvm,jvm,java,开发语言,笔记)