JDK 14 里的调试神器了解一下?
回复“资源”获取独家整理的学习资料!
jcmd [pid | main-class] command... | PerfCounter.print | -f filenamejcmd [-l]jcmd -h
./jcmd 93989 help93989:The following commands are available:Compiler.CodeHeap_AnalyticsCompiler.codecacheCompiler.codelistCompiler.directives_addCompiler.directives_clearCompiler.directives_printCompiler.directives_removeCompiler.queueGC.class_histogramGC.class_statsGC.finalizer_infoGC.heap_dumpGC.heap_infoGC.runGC.run_finalizationJFR.checkJFR.configureJFR.dumpJFR.startJFR.stopJVMTI.agent_loadJVMTI.data_dumpManagementAgent.startManagementAgent.start_localManagementAgent.statusManagementAgent.stopThread.printVM.class_hierarchyVM.classloader_statsVM.classloadersVM.command_lineVM.dynlibsVM.eventsVM.flagsVM.infoVM.logVM.metaspaceVM.native_memoryVM.print_touched_methodsVM.set_flagVM.stringtableVM.symboltableVM.system_propertiesVM.systemdictionaryVM.uptimeVM.versionhelp
- -f filename表示从文本文件中读取要运行的命令。 
- -l 列出不是运行在docker中JVM。 
- -h 表示帮助。 
下面我们举几个常用的例子。
./jcmd -l98109 jdk.jcmd/sun.tools.jcmd.JCmd -l
./jcmd 93989 Thread.print -lFull thread dump Java HotSpot(TM) 64-Bit Server VM (14.0.1+7 mixed mode, sharing):Threads class SMR info:_java_thread_list=0x00007fbeb1c4cb10, length=12, elements={0x00007fbeb282a800, 0x00007fbeb282d800, 0x00007fbeb282e800, 0x00007fbeb2830800,0x00007fbeb2831800, 0x00007fbeb2832000, 0x00007fbeb2833000, 0x00007fbeb3831000,0x00007fbeb3822000, 0x00007fbeb3174000, 0x00007fbeb3815000, 0x00007fbeb226f800}"Reference Handler" #2 daemon prio=10 os_prio=31 cpu=0.64ms elapsed=8996.59s tid=0x00007fbeb282a800 nid=0x4703 waiting on condition [0x000070000440d000]java.lang.Thread.State: RUNNABLEat java.lang.ref.Reference.waitForReferencePendingList([email protected]/Native Method)at java.lang.ref.Reference.processPendingReferences([email protected]/Reference.java:241)at java.lang.ref.Reference$ReferenceHandler.run([email protected]/Reference.java:213)Locked ownable synchronizers:- None
./jcmd 93989 GC.heap_dump heap_dump.out93989:Dumping heap to heap_dump.out ...Heap dump file created [27727979 bytes in 0.643 secs]
./jcmd 93989 GC.heap_dump heap_dump.out93989:Dumping heap to heap_dump.out ...Heap dump file created [27727979 bytes in 0.643 secs]
./jcmd 93989 GC.class_histogram93989:num #instances #bytes class name (module)-------------------------------------------------------1: 25826 11748304 [B (java.base@14.0.1)2: 2233 1971800 [I (java.base@14.0.1)3: 5154 614928 java.lang.Class (java.base@14.0.1)4: 24757 594168 java.lang.String (java.base@14.0.1)5: 4491 439432 [Ljava.lang.Object; (java.base@14.0.1)6: 13177 421664 java.util.concurrent.ConcurrentHashMap$Node (java.base@14.0.1)7: 5025 160800 java.util.HashMap$Node (java.base@14.0.1)8: 8793 140688 java.lang.Object (java.base@14.0.1)9: 212 103584 [Ljava.util.concurrent.ConcurrentHashMap$Node; (java.base@14.0.1)
往期推荐
扫一扫,关注我
一起学习,一起进步
