展示 进程运行的完整命令行的话可以用 top -c ,当命令行较长无法分辨是哪个程序,可使用键盘右键将窗口不断滑动至右侧查看。
查看当前正在运行的java进程
执行结果: pid 运行文件
[root@test1 ~]# jps 24001 rs-medical-rpc-service.jar 25602 rs-recure-rpc-service.jar 9122 rs-patient-rpc-service.jar 24836 rs-open-rpc-service.jar 10533 rs-message-rpc-service.jar 8650 rs-all-admin.jar 20395 rs-member-server.jar 1932 rs-member-rpc-service.jar 24140 Jps 26159 rs-report-rpc-service.jar 5935 rs-followup-rpc-service.jar 26448 rs-upms-rpc-service.jar 5267 rs-visit-rpc-service.jar 8052 Bootstrap 3799 jar 27095 rs-education-rpc-service.jar 22936 rs-job-rpc-service.jar 12793 jar 25881 rs-register-rpc-service.jar 23708 rs-external-rpc-service.jar 7997 Bootstrap 13055 QuorumPeerMain 25183 rs-oss-rpc-service.jar [root@test1 ~]# jps -l 24001 /opt/rs-medical-rpc-service/rs-medical-rpc-service.jar 25602 /opt/rs-recure-rpc-service/rs-recure-rpc-service.jar 9122 /opt/rs-patient-rpc-service/rs-patient-rpc-service.jar 24836 /opt/rs-open-rpc-service/rs-open-rpc-service.jar 10533 /opt/rs-message-rpc-service/rs-message-rpc-service.jar 8650 /opt/rs-all-admin/rs-all-admin.jar 20395 /opt/rs-member-server/rs-member-server.jar 1932 /opt/rs-member-rpc-service/rs-member-rpc-service.jar 26159 /opt/rs-report-rpc-service/rs-report-rpc-service.jar 5935 /opt/rs-followup-rpc-service/rs-followup-rpc-service.jar 26448 /opt/rs-upms-rpc-service/rs-upms-rpc-service.jar 5267 /opt/rs-visit-rpc-service/rs-visit-rpc-service.jar 8052 org.apache.catalina.startup.Bootstrap 3799 spring-boot-admin-0.0.1-SNAPSHOT.jar 27095 /opt/rs-education-rpc-service/rs-education-rpc-service.jar 22936 /opt/rs-job-rpc-service/rs-job-rpc-service.jar 12793 xxl-job-admin-2.1.2.jar 25881 /opt/rs-register-rpc-service/rs-register-rpc-service.jar 23708 /opt/rs-external-rpc-service/rs-external-rpc-service.jar 7997 org.apache.catalina.startup.Bootstrap 24189 sun.tools.jps.Jps 13055 org.apache.zookeeper.server.quorum.QuorumPeerMain 25183 /opt/rs-oss-rpc-service/rs-oss-rpc-service.jar [root@test1 ~]#
jstat -
[root@test1 ~]# jstat -gc 25183 S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT 26176.0 26176.0 662.4 0.0 209792.0 15089.7 786432.0 58931.7 97168.0 92924.0 11688.0 10872.9 306 11.508 6 0.106 11.614 [root@test1 ~]# jstat -gcutil 25183 S0 S1 E O P YGC YGCT FGC FGCT GCT 0.00 0.00 6.20 41.42 47.20 16 0.105 3 0.472 0.577
这台服务器的新生代Eden区(E,表示Eden)使用了6.2%的空间,2个Survivor区 (S0、S1,表示Survivor0、Survivor1)里面都是空的,老年代(O,表示Old)和永久代(P,表示 Permanent)则分别使用了41.42%和47.20%的空间。程序运行以来共发生Minor GC(YGC,表示Young GC)16次,总耗时0.105秒;发生Full GC(FGC,表示Full GC)3次,总耗时(FGCT,表示Full GC Time)为0.472秒;所有GC总耗时(GCT,表示GC Time)为0.577秒。
jinfo(Configuration Info for Java)的作用是实时查看和调整虚拟机各项参数。
[root@test1 ~]# jinfo 25183 Attaching to process ID 25183, please wait... Debugger attached successfully. Server compiler detected. JVM version is 25.322-b06 Java System Properties: java.runtime.name = OpenJDK Runtime Environment java.vm.version = 25.322-b06 sun.boot.library.path = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/amd64 java.protocol.handler.pkgs = org.springframework.boot.loader java.vendor.url = https://www.redhat.com/ java.vm.vendor = Red Hat, Inc. path.separator = : file.encoding.pkg = sun.io java.vm.name = OpenJDK 64-Bit Server VM sun.os.patch.level = unknown sun.java.launcher = SUN_STANDARD user.country = CN user.dir = /root java.vm.specification.name = Java Virtual Machine Specification PID = 25183 java.runtime.version = 1.8.0_322-b06 java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment os.arch = amd64 java.endorsed.dirs = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/endorsed line.separator = java.io.tmpdir = /tmp java.vm.specification.vendor = Oracle Corporation os.name = Linux spring.config.location = /opt/rs-oss-rpc-service/conf/application.properties sun.jnu.encoding = UTF-8 java.library.path = /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib spring.beaninfo.ignore = true sun.nio.ch.bugLevel = java.specification.name = Java Platform API Specification java.class.version = 52.0 java.net.preferIPv4Stack = true sun.management.compiler = HotSpot 64-Bit Tiered Compilers os.version = 3.10.0-957.el7.x86_64 LOG_FILE = /root/logs/@[email protected] user.home = /root user.timezone = Asia/Shanghai catalina.useNaming = false java.awt.printerjob = sun.print.PSPrinterJob file.encoding = UTF-8 java.specification.version = 1.8 catalina.home = /tmp/tomcat.378295779052555567.8205 user.name = root java.class.path = /opt/rs-oss-rpc-service/rs-oss-rpc-service.jar java.vm.specification.version = 1.8 sun.arch.data.model = 64 sun.java.command = /opt/rs-oss-rpc-service/rs-oss-rpc-service.jar java.home = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre user.language = zh java.specification.vendor = Oracle Corporation org.apache.logging.log4j.assignedSequences = 4441 awt.toolkit = sun.awt.X11.XToolkit java.vm.info = mixed mode java.version = 1.8.0_322 java.ext.dirs = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/ext:/usr/java/packages/lib/ext sun.boot.class.path = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/resources.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/rt.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/jsse.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/jce.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/charsets.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/jfr.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/classes java.awt.headless = true java.vendor = Red Hat, Inc. catalina.base = /tmp/tomcat.378295779052555567.8205 file.separator = / java.vendor.url.bug = https://bugzilla.redhat.com/enter_bug.cgi?product=Red%20Hat%20Enterprise%20Linux%207&component=java-1.8.0-openjdk sun.io.unicode.encoding = UnicodeLittle sun.cpu.endian = little sun.cpu.isalist = VM Flags: Non-default VM flags: -XX:CICompilerCount=12 -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:+DisableExplicitGC -XX:InitialHeapSize=1073741824 -XX:LargePageSizeInBytes=134217728 -XX:MaxHeapSize=1073741824 -XX:MaxNewSize=268435456 -XX:MaxTenuringThreshold=6 -XX:MinHeapDeltaBytes=196608 -XX:NewSize=268435456 -XX:OldPLABSize=16 -XX:OldSize=805306368 -XX:ThreadStackSize=256 -XX:+UseCMSCompactAtFullCollection -XX:+UseCMSInitiatingOccupancyOnly -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+UseFastAccessorMethods -XX:+UseFastUnorderedTimeStamps -XX:+UseParNewGC Command line: -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Xmx1g -Xms1g -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 -Dspring.config.location=/opt/rs-oss-rpc-service/conf/application.properties
jstack(Stack Trace for Java)命令用于生成虚拟机当前时刻的线程快照(一般称为threaddump或者 javacore文件)。线程快照就是当前虚拟机内每一条线程正在执行的方法堆栈的集合,生成线程快照的
目的通常是定位线程出现长时间停顿的原因,如线程间死锁、死循环、请求外部资源导致的长时间挂
起等,都是导致线程长时间停顿的常见原因。线程出现停顿时通过jstack来查看各个线程的调用堆栈,
就可以获知没有响应的线程到底在后台做些什么事情,或者等待着什么资源。
# jstack -l pid -l 除堆栈信息外显示关于锁的附加信息 "Druid-ConnectionPool-Create-1534755892" #32 daemon prio=5 os_prio=0 tid=0x00007f4cb98f5000 nid=0x6384 waiting on condition [0x00007f4c400cf000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000000d12778b8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2728) Locked ownable synchronizers: - None "Druid-ConnectionPool-Destroy-380812044" #31 daemon prio=5 os_prio=0 tid=0x00007f4cb8f9a000 nid=0x6383 waiting on condition [0x00007f4c40110000] java.lang.Thread.State: TIMED_WAITING (sleeping) at java.lang.Thread.sleep(Native Method) at com.alibaba.druid.pool.DruidDataSource$DestroyConnectionThread.run(DruidDataSource.java:2824) Locked ownable synchronizers: - None "Druid-ConnectionPool-Create-380812044" #30 daemon prio=5 os_prio=0 tid=0x00007f4cb8c87000 nid=0x6382 waiting on condition [0x00007f4c40151000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000000d14761f8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2728) Locked ownable synchronizers: - None "mysql-cj-abandoned-connection-cleanup" #29 daemon prio=5 os_prio=0 tid=0x00007f4cb9882000 nid=0x6380 in Object.wait() [0x00007f4c40192000] java.lang.Thread.State: TIMED_WAITING (on object monitor) at java.lang.Object.wait(Native Method) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:144) - locked <0x00000000d1760620> (a java.lang.ref.ReferenceQueue$Lock) at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:85) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750) Locked ownable synchronizers: - <0x00000000d16d1078> (a java.util.concurrent.ThreadPoolExecutor$Worker) "Statistics Thread-__DEFAULT__-1" #27 daemon prio=5 os_prio=0 tid=0x00007f4cb84dd800 nid=0x6378 waiting on condition [0x00007f4c401d3000] java.lang.Thread.State: TIMED_WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000000d146b0d8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750) Locked ownable synchronizers: - None "rs-oss-rpc-service.data" #26 prio=5 os_prio=0 tid=0x00007f4cb9428000 nid=0x6377 waiting on condition [0x00007f4c41496000] java.lang.Thread.State: TIMED_WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000000d1464758> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750) Locked ownable synchronizers: - None "__DEFAULT__" #25 daemon prio=5 os_prio=0 tid=0x00007f4cb91c2000 nid=0x6376 in Object.wait() [0x00007f4c41055000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000000d1412140> (a java.util.TaskQueue) at java.lang.Object.wait(Object.java:502) at java.util.TimerThread.mainLoop(Timer.java:526) - locked <0x00000000d1412140> (a java.util.TaskQueue) at java.util.TimerThread.run(Timer.java:505) Locked ownable synchronizers: - None "Log4j2-TF-4-Scheduled-2" #22 daemon prio=5 os_prio=0 tid=0x00007f4cb84e0000 nid=0x6323 waiting on condition [0x00007f4c40c14000] java.lang.Thread.State: TIMED_WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000000d07034a8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750) Locked ownable synchronizers: - None "Service Thread" #18 daemon prio=9 os_prio=0 tid=0x00007f4cb838b800 nid=0x628c runnable [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C1 CompilerThread11" #17 daemon prio=9 os_prio=0 tid=0x00007f4cb8388000 nid=0x628b runnable [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C1 CompilerThread10" #16 daemon prio=9 os_prio=0 tid=0x00007f4cb8386000 nid=0x628a waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C1 CompilerThread9" #15 daemon prio=9 os_prio=0 tid=0x00007f4cb8384000 nid=0x6289 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C1 CompilerThread8" #14 daemon prio=9 os_prio=0 tid=0x00007f4cb8381000 nid=0x6288 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C2 CompilerThread7" #13 daemon prio=9 os_prio=0 tid=0x00007f4cb837e800 nid=0x6287 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C2 CompilerThread6" #12 daemon prio=9 os_prio=0 tid=0x00007f4cb837c800 nid=0x6286 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C2 CompilerThread5" #11 daemon prio=9 os_prio=0 tid=0x00007f4cb837a000 nid=0x6285 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C2 CompilerThread4" #10 daemon prio=9 os_prio=0 tid=0x00007f4cb8378000 nid=0x6284 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C2 CompilerThread3" #9 daemon prio=9 os_prio=0 tid=0x00007f4cb8375800 nid=0x6283 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C2 CompilerThread2" #8 daemon prio=9 os_prio=0 tid=0x00007f4cb836b000 nid=0x6282 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C2 CompilerThread1" #7 daemon prio=9 os_prio=0 tid=0x00007f4cb8369000 nid=0x6281 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C2 CompilerThread0" #6 daemon prio=9 os_prio=0 tid=0x00007f4cb8366800 nid=0x6280 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "Signal Dispatcher" #5 daemon prio=9 os_prio=0 tid=0x00007f4cb8358800 nid=0x627f runnable [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "Surrogate Locker Thread (Concurrent GC)" #4 daemon prio=9 os_prio=0 tid=0x00007f4cb8356800 nid=0x627e waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "Finalizer" #3 daemon prio=8 os_prio=0 tid=0x00007f4cb832a800 nid=0x627c in Object.wait() [0x00007f4ca0e85000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:144) - locked <0x00000000d00218a8> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:165) at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:216) Locked ownable synchronizers: - None "Reference Handler" #2 daemon prio=10 os_prio=0 tid=0x00007f4cb8326000 nid=0x627b in Object.wait() [0x00007f4ca0ec6000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Object.java:502) at java.lang.ref.Reference.tryHandlePending(Reference.java:191) - locked <0x00000000d00291d0> (a java.lang.ref.Reference$Lock) at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153) Locked ownable synchronizers: - None "VM Thread" os_prio=0 tid=0x00007f4cb831c000 nid=0x627a runnable "Gang worker#0 (Parallel GC Threads)" os_prio=0 tid=0x00007f4cb805a800 nid=0x6268 runnable "Gang worker#1 (Parallel GC Threads)" os_prio=0 tid=0x00007f4cb805c800 nid=0x6269 runnable "Gang worker#2 (Parallel GC Threads)" os_prio=0 tid=0x00007f4cb805e000 nid=0x626a runnable "Gang worker#3 (Parallel GC Threads)" os_prio=0 tid=0x00007f4cb8060000 nid=0x626b runnable "Gang worker#4 (Parallel GC Threads)" os_prio=0 tid=0x00007f4cb8062000 nid=0x626c runnable "Gang worker#5 (Parallel GC Threads)" os_prio=0 tid=0x00007f4cb8064000 nid=0x626d runnable "Gang worker#6 (Parallel GC Threads)" os_prio=0 tid=0x00007f4cb8065800 nid=0x626e runnable "Gang worker#7 (Parallel GC Threads)" os_prio=0 tid=0x00007f4cb8067800 nid=0x626f runnable "Gang worker#8 (Parallel GC Threads)" os_prio=0 tid=0x00007f4cb8069800 nid=0x6270 runnable "Gang worker#9 (Parallel GC Threads)" os_prio=0 tid=0x00007f4cb806b800 nid=0x6271 runnable "Gang worker#10 (Parallel GC Threads)" os_prio=0 tid=0x00007f4cb806d000 nid=0x6272 runnable "Gang worker#11 (Parallel GC Threads)" os_prio=0 tid=0x00007f4cb806f000 nid=0x6273 runnable "Gang worker#12 (Parallel GC Threads)" os_prio=0 tid=0x00007f4cb8071000 nid=0x6274 runnable "Concurrent Mark-Sweep GC Thread" os_prio=0 tid=0x00007f4cb811c800 nid=0x6279 runnable "Gang worker#0 (Parallel CMS Threads)" os_prio=0 tid=0x00007f4cb8114000 nid=0x6275 runnable "Gang worker#1 (Parallel CMS Threads)" os_prio=0 tid=0x00007f4cb8115800 nid=0x6276 runnable "Gang worker#2 (Parallel CMS Threads)" os_prio=0 tid=0x00007f4cb8117800 nid=0x6277 runnable "Gang worker#3 (Parallel CMS Threads)" os_prio=0 tid=0x00007f4cb8119800 nid=0x6278 runnable "VM Periodic Task Thread" os_prio=0 tid=0x00007f4cb838d800 nid=0x628d waiting on condition JNI global references: 1925
jmap(Memory Map for Java)命令用于生成堆转储快照(一般称为heapdump或dump文件)。
# jmap pid # jmap -dump:format=b,file=yourfilename.bin 3500 # -dump 用于生成堆栈转存储快照,format=b指定格式化,file中定义自己的文件名 3500表示当前进程id [root@test1 ~]# jmap 25183 Attaching to process ID 25183, please wait... Debugger attached successfully. Server compiler detected. JVM version is 25.322-b06 0x000055bb71638000 8K /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/bin/java 0x00007f4bf9ed8000 123K /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/amd64/libsunec.so 0x00007f4c41898000 153K /usr/lib64/liblzma.so.5.2.2 0x00007f4c7000a000 66K /usr/lib64/libbz2.so.1.0.6 0x00007f4c7021a000 97K /usr/lib64/libelf-0.172.so 0x00007f4c70432000 19K /usr/lib64/libattr.so.1.1.0 0x00007f4c70637000 322K /usr/lib64/libdw-0.172.so 0x00007f4c70886000 19K /usr/lib64/libcap.so.2.22 0x00007f4c70a8b000 84K /usr/lib64/libnss_myhostname.so.2 0x00007f4c70ca0000 107K /usr/lib64/libresolv-2.17.so 0x00007f4c70eba000 30K /usr/lib64/libnss_dns-2.17.so 0x00007f4c710c1000 51K /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/amd64/libmanagement.so 0x00007f4c712cb000 121K /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/amd64/libnet.so 0x00007f4c714e4000 97K /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/amd64/libnio.so 0x00007f4cbc07c000 43K /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/amd64/libzip.so 0x00007f4cbc285000 60K /usr/lib64/libnss_files-2.17.so 0x00007f4cbc498000 214K /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/amd64/libjava.so 0x00007f4cbc6c4000 64K /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/amd64/libverify.so 0x00007f4cbc8d3000 42K /usr/lib64/librt-2.17.so 0x00007f4cbcadb000 86K /usr/lib64/libgcc_s-4.8.5-20150702.so.1 0x00007f4cbccf1000 1110K /usr/lib64/libm-2.17.so 0x00007f4cbcff3000 968K /usr/lib64/libstdc++.so.6.0.19 0x00007f4cbd2fa000 17660K /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/amd64/server/libjvm.so 0x00007f4cbe3a5000 2106K /usr/lib64/libc-2.17.so 0x00007f4cbe773000 18K /usr/lib64/libdl-2.17.so 0x00007f4cbe977000 69K /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/lib/amd64/jli/libjli.so 0x00007f4cbeb86000 88K /usr/lib64/libz.so.1.2.7 0x00007f4cbed9c000 138K /usr/lib64/libpthread-2.17.so 0x00007f4cbefb8000 159K /usr/lib64/ld-2.17.so