JVM 监控 - jps jstack jmap top jhat

2024-01-16 13:08
文章标签 java jvm top 监控 jmap jstack jps jhat

本文主要是介绍JVM 监控 - jps jstack jmap top jhat,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

  1. jps 查看 java 进程信息
  2. jstack 可查看java进程里的存活线程状态
  3. jmap 可查看java进程堆内存使用情况
  4. top linux 命令,可查看java某进程的线程
  5. jhat 可查看dump文件
  • jps  
    • jps 简单列出java进程 
[root@localhost app]# jps
5666 WatchdogServer
5746 XmlAppTransporterContext
5683 Bootstrap
10515 Jps
11929 XmlAppTransporterContext
11915 WatchdogServer

 

  • jstack 
    • jstack [pid] -> jstack 5666 列出指定进程下的线程情况
    • jstack [pid] | grep '关键字' -> jstack 5666 | grep 'RUNNABLE' 同上带有过滤
[root@localhost app]# jstack 5666
2019-04-04 16:10:28
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.181-b13 mixed mode):"Attach Listener" #30 daemon prio=9 os_prio=0 tid=0x00007f7998002800 nid=0x6bf7 waiting on condition [0x0000000000000000]java.lang.Thread.State: RUNNABLE"pool-4-thread-1" #29 prio=5 os_prio=0 tid=0x00007f798c04b000 nid=0x1664 waiting on condition [0x00007f79bd8d0000]java.lang.Thread.State: WAITING (parking)at sun.misc.Unsafe.park(Native Method)- parking to wait for  <0x00000000ca803bf8> (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 java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:403)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:748)"JMX client heartbeat 3" #28 daemon prio=5 os_prio=0 tid=0x00007f798c041800 nid=0x1663 waiting on condition [0x00007f79bd9d1000]java.lang.Thread.State: TIMED_WAITING (sleeping)at java.lang.Thread.sleep(Native Method)at com.sun.jmx.remote.internal.ClientCommunicatorAdmin$Checker.run(ClientCommunicatorAdmin.java:175)at java.lang.Thread.run(Thread.java:748)"RMI RenewClean-[127.0.0.1:37134]" #27 daemon prio=5 os_prio=0 tid=0x00007f798c03f800 nid=0x165f in Object.wait() [0x00007f79bdad2000]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 <0x00000000ca7faaf0> (a java.lang.ref.ReferenceQueue$Lock)at sun.rmi.transport.DGCClient$EndpointEntry$RenewCleanThread.run(DGCClient.java:563)at java.lang.Thread.run(Thread.java:748)"input-stream-pool-1" #26 prio=5 os_prio=0 tid=0x00007f798c015800 nid=0x165b waiting on condition [0x00007f79bddde000]java.lang.Thread.State: WAITING (parking)at sun.misc.Unsafe.park(Native Method)- parking to wait for  <0x00000000ca7b5548> (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 java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)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:748)"input-stream-pool-0" #25 prio=5 os_prio=0 tid=0x00007f798c014000 nid=0x165a runnable [0x00007f79bdedf000]java.lang.Thread.State: RUNNABLEat java.io.FileInputStream.readBytes(Native Method)at java.io.FileInputStream.read(FileInputStream.java:255)at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)at java.io.BufferedInputStream.read(BufferedInputStream.java:345)- locked <0x00000000ca7c26c8> (a java.lang.UNIXProcess$ProcessPipeInputStream)at com.creditease.ns4.gear.watchdog.monitor.process.WatchdogChildProcess.readInputStream(WatchdogChildProcess.java:85)at com.creditease.ns4.gear.watchdog.monitor.process.WatchdogChildProcess.access$000(WatchdogChildProcess.java:38)at com.creditease.ns4.gear.watchdog.monitor.process.WatchdogChildProcess$1.run(WatchdogChildProcess.java:127)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:748)"DestroyJavaVM" #24 prio=5 os_prio=0 tid=0x00007f79dc00b000 nid=0x1623 waiting on condition [0x0000000000000000]java.lang.Thread.State: RUNNABLE

 

  • jmap 
    • jmap -heap [pid] -> jmap -heap 5666 列出指定进程的堆内存使用情况
[root@localhost app]# jmap -heap 5666
Attaching to process ID 5666, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.181-b13using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GCHeap Configuration:MinHeapFreeRatio         = 40MaxHeapFreeRatio         = 70MaxHeapSize              = 1073741824 (1024.0MB)NewSize                  = 174456832 (166.375MB)MaxNewSize               = 174456832 (166.375MB)OldSize                  = 899284992 (857.625MB)NewRatio                 = 2SurvivorRatio            = 8MetaspaceSize            = 21807104 (20.796875MB)CompressedClassSpaceSize = 1073741824 (1024.0MB)MaxMetaspaceSize         = 17592186044415 MBG1HeapRegionSize         = 0 (0.0MB)Heap Usage:
New Generation (Eden + 1 Survivor Space):capacity = 157024256 (149.75MB)used     = 9306376 (8.875251770019531MB)free     = 147717880 (140.87474822998047MB)5.926712367291841% used
Eden Space:capacity = 139591680 (133.125MB)used     = 9306376 (8.875251770019531MB)free     = 130285304 (124.24974822998047MB)6.666855789686033% used
From Space:capacity = 17432576 (16.625MB)used     = 0 (0.0MB)free     = 17432576 (16.625MB)0.0% used
To Space:capacity = 17432576 (16.625MB)used     = 0 (0.0MB)free     = 17432576 (16.625MB)0.0% used
concurrent mark-sweep generation:capacity = 899284992 (857.625MB)used     = 2130744 (2.0320358276367188MB)free     = 897154248 (855.5929641723633MB)0.2369375691749563% used4999 interned Strings occupying 395840 bytes.
  • jmap -histo[:live] [pid] -> jmap -histo:live 5666 关键字live列出存活对象
 num     #instances         #bytes  class name
----------------------------------------------1:          8633         556016  [C2:          2168         245408  java.lang.Class3:          8621         206904  java.lang.String4:           544         188632  [B5:          1896         101440  [Ljava.lang.Object;6:           551          48488  java.lang.reflect.Method7:           873          48064  [I8:          1382          44224  java.util.HashMap$Node9:          1303          41696  java.util.concurrent.ConcurrentHashMap$Node10:           203          23200  [Ljava.util.HashMap$Node;11:          1143          18288  java.lang.Object12:           390          15600  java.lang.ref.SoftReference13:           429          14880  [Ljava.lang.String;14:            41          14704  [Ljava.util.concurrent.ConcurrentHashMap$Node;15:           395          12640  java.util.Hashtable$Entry16:           221          12376  java.lang.invoke.MemberName17:           480          11608  [Ljava.lang.Class;18:           239          11472  java.util.HashMap19:           341          10912  sun.misc.FDBigInteger20:            24           9024  java.lang.Thread21:           219           8760  java.util.LinkedHashMap$Entry22:           291           6984  java.lang.Long23:           206           6592  java.lang.invoke.LambdaForm$Name24:            74           6528  [Ljava.util.WeakHashMap$Entry;25:           102           6528  java.net.URL26:           158           6320  java.lang.invoke.MethodType27:            96           5760  [Ljava.lang.ref.SoftReference;28:            71           5680  java.lang.reflect.Constructor29:           229           5496  javax.management.ImmutableDescriptor30:            50           5448  [Ljava.util.Hashtable$Entry;31:           167           5344  java.lang.invoke.MethodType$ConcurrentWeakInternSet$WeakEntry32:           166           5312  com.sun.jmx.mbeanserver.ConvertingMethod33:           126           5040  java.util.WeakHashMap$Entry34:           279           4464  java.lang.Integer35:            67           4288  javax.management.openmbean.OpenMBeanAttributeInfoSupport36:           256           4096  java.lang.Byte37:           256           4096  java.lang.Short38:           102           4080  java.lang.ref.Finalizer39:           123           3936  java.lang.ref.WeakReference40:            92           3680  java.util.TreeMap$Entry41:            71           3408  java.util.WeakHashMap42:            71           3408  java.util.logging.LogManager$LoggerWeakRef43:            68           3264  java.lang.invoke.LambdaForm44:            73           3248  [Ljava.lang.invoke.LambdaForm$Name;45:           173           3144  [Lcom.sun.jmx.mbeanserver.MXBeanMapping;46:            94           3008  java.lang.ref.ReferenceQueue47:            54           2968  [Ljavax.management.MBeanAttributeInfo;
  • class name 列说明
B  byte 
C  char 
D  double 
F  float 
I  int 
J  long 
Z  boolean 
[  数组,如[I表示int[] [L+类名 其他对象
  • jmap -dump:format=b,file=[filename] [pid] -> jmap -dump:format=b,file=./dump.dat 5666 给指定进程生成dump
  • jhat -port 9999 ./dump.dat 查看生成的dump,浏览器打开:http://localhost:9999

上面图片是引用其他文章-Other Queries 最后一项支持OQL(对象查询语言)

这篇关于JVM 监控 - jps jstack jmap top jhat的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/612701

相关文章

Java编译生成多个.class文件的原理和作用

《Java编译生成多个.class文件的原理和作用》作为一名经验丰富的开发者,在Java项目中执行编译后,可能会发现一个.java源文件有时会产生多个.class文件,从技术实现层面详细剖析这一现象... 目录一、内部类机制与.class文件生成成员内部类(常规内部类)局部内部类(方法内部类)匿名内部类二、

SpringBoot实现数据库读写分离的3种方法小结

《SpringBoot实现数据库读写分离的3种方法小结》为了提高系统的读写性能和可用性,读写分离是一种经典的数据库架构模式,在SpringBoot应用中,有多种方式可以实现数据库读写分离,本文将介绍三... 目录一、数据库读写分离概述二、方案一:基于AbstractRoutingDataSource实现动态

Springboot @Autowired和@Resource的区别解析

《Springboot@Autowired和@Resource的区别解析》@Resource是JDK提供的注解,只是Spring在实现上提供了这个注解的功能支持,本文给大家介绍Springboot@... 目录【一】定义【1】@Autowired【2】@Resource【二】区别【1】包含的属性不同【2】@

springboot循环依赖问题案例代码及解决办法

《springboot循环依赖问题案例代码及解决办法》在SpringBoot中,如果两个或多个Bean之间存在循环依赖(即BeanA依赖BeanB,而BeanB又依赖BeanA),会导致Spring的... 目录1. 什么是循环依赖?2. 循环依赖的场景案例3. 解决循环依赖的常见方法方法 1:使用 @La

Java枚举类实现Key-Value映射的多种实现方式

《Java枚举类实现Key-Value映射的多种实现方式》在Java开发中,枚举(Enum)是一种特殊的类,本文将详细介绍Java枚举类实现key-value映射的多种方式,有需要的小伙伴可以根据需要... 目录前言一、基础实现方式1.1 为枚举添加属性和构造方法二、http://www.cppcns.co

Elasticsearch 在 Java 中的使用教程

《Elasticsearch在Java中的使用教程》Elasticsearch是一个分布式搜索和分析引擎,基于ApacheLucene构建,能够实现实时数据的存储、搜索、和分析,它广泛应用于全文... 目录1. Elasticsearch 简介2. 环境准备2.1 安装 Elasticsearch2.2 J

Java中的String.valueOf()和toString()方法区别小结

《Java中的String.valueOf()和toString()方法区别小结》字符串操作是开发者日常编程任务中不可或缺的一部分,转换为字符串是一种常见需求,其中最常见的就是String.value... 目录String.valueOf()方法方法定义方法实现使用示例使用场景toString()方法方法

Java中List的contains()方法的使用小结

《Java中List的contains()方法的使用小结》List的contains()方法用于检查列表中是否包含指定的元素,借助equals()方法进行判断,下面就来介绍Java中List的c... 目录详细展开1. 方法签名2. 工作原理3. 使用示例4. 注意事项总结结论:List 的 contain

Java实现文件图片的预览和下载功能

《Java实现文件图片的预览和下载功能》这篇文章主要为大家详细介绍了如何使用Java实现文件图片的预览和下载功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... Java实现文件(图片)的预览和下载 @ApiOperation("访问文件") @GetMapping("

Spring Boot + MyBatis Plus 高效开发实战从入门到进阶优化(推荐)

《SpringBoot+MyBatisPlus高效开发实战从入门到进阶优化(推荐)》本文将详细介绍SpringBoot+MyBatisPlus的完整开发流程,并深入剖析分页查询、批量操作、动... 目录Spring Boot + MyBATis Plus 高效开发实战:从入门到进阶优化1. MyBatis