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

相关文章

JVM 的类初始化机制

前言 当你在 Java 程序中new对象时,有没有考虑过 JVM 是如何把静态的字节码(byte code)转化为运行时对象的呢,这个问题看似简单,但清楚的同学相信也不会太多,这篇文章首先介绍 JVM 类初始化的机制,然后给出几个易出错的实例来分析,帮助大家更好理解这个知识点。 JVM 将字节码转化为运行时对象分为三个阶段,分别是:loading 、Linking、initialization

Spring Security 基于表达式的权限控制

前言 spring security 3.0已经可以使用spring el表达式来控制授权,允许在表达式中使用复杂的布尔逻辑来控制访问的权限。 常见的表达式 Spring Security可用表达式对象的基类是SecurityExpressionRoot。 表达式描述hasRole([role])用户拥有制定的角色时返回true (Spring security默认会带有ROLE_前缀),去

浅析Spring Security认证过程

类图 为了方便理解Spring Security认证流程,特意画了如下的类图,包含相关的核心认证类 概述 核心验证器 AuthenticationManager 该对象提供了认证方法的入口,接收一个Authentiaton对象作为参数; public interface AuthenticationManager {Authentication authenticate(Authenti

Spring Security--Architecture Overview

1 核心组件 这一节主要介绍一些在Spring Security中常见且核心的Java类,它们之间的依赖,构建起了整个框架。想要理解整个架构,最起码得对这些类眼熟。 1.1 SecurityContextHolder SecurityContextHolder用于存储安全上下文(security context)的信息。当前操作的用户是谁,该用户是否已经被认证,他拥有哪些角色权限…这些都被保

Spring Security基于数据库验证流程详解

Spring Security 校验流程图 相关解释说明(认真看哦) AbstractAuthenticationProcessingFilter 抽象类 /*** 调用 #requiresAuthentication(HttpServletRequest, HttpServletResponse) 决定是否需要进行验证操作。* 如果需要验证,则会调用 #attemptAuthentica

Spring Security 从入门到进阶系列教程

Spring Security 入门系列 《保护 Web 应用的安全》 《Spring-Security-入门(一):登录与退出》 《Spring-Security-入门(二):基于数据库验证》 《Spring-Security-入门(三):密码加密》 《Spring-Security-入门(四):自定义-Filter》 《Spring-Security-入门(五):在 Sprin

Java架构师知识体认识

源码分析 常用设计模式 Proxy代理模式Factory工厂模式Singleton单例模式Delegate委派模式Strategy策略模式Prototype原型模式Template模板模式 Spring5 beans 接口实例化代理Bean操作 Context Ioc容器设计原理及高级特性Aop设计原理Factorybean与Beanfactory Transaction 声明式事物

流媒体平台/视频监控/安防视频汇聚EasyCVR播放暂停后视频画面黑屏是什么原因?

视频智能分析/视频监控/安防监控综合管理系统EasyCVR视频汇聚融合平台,是TSINGSEE青犀视频垂直深耕音视频流媒体技术、AI智能技术领域的杰出成果。该平台以其强大的视频处理、汇聚与融合能力,在构建全栈视频监控系统中展现出了独特的优势。视频监控管理系统EasyCVR平台内置了强大的视频解码、转码、压缩等技术,能够处理多种视频流格式,并以多种格式(RTMP、RTSP、HTTP-FLV、WebS

Java进阶13讲__第12讲_1/2

多线程、线程池 1.  线程概念 1.1  什么是线程 1.2  线程的好处 2.   创建线程的三种方式 注意事项 2.1  继承Thread类 2.1.1 认识  2.1.2  编码实现  package cn.hdc.oop10.Thread;import org.slf4j.Logger;import org.slf4j.LoggerFactory

综合安防管理平台LntonAIServer视频监控汇聚抖动检测算法优势

LntonAIServer视频质量诊断功能中的抖动检测是一个专门针对视频稳定性进行分析的功能。抖动通常是指视频帧之间的不必要运动,这种运动可能是由于摄像机的移动、传输中的错误或编解码问题导致的。抖动检测对于确保视频内容的平滑性和观看体验至关重要。 优势 1. 提高图像质量 - 清晰度提升:减少抖动,提高图像的清晰度和细节表现力,使得监控画面更加真实可信。 - 细节增强:在低光条件下,抖