JMAP

Java之JVM监控工具分享

我怕爱的太早我们不能终老 提交于 2019-11-26 22:17:57
Java之JVM监控工具分享 JVM的基本知识常用的也就是 类加载机制 , 内存区域、分配、OOM , GC , JVM参数调优 几个链接自己看: 内存区域&类加载机制 分配策略&垃圾回收算法、收集器 今天结合代码讲一讲常用的java自带工具讲解,这些命令一般都是jdk/lib/tools.jar中。用来监控诊断我们的Java环境。 官方说明: https://docs.oracle.com/en/java/javase/11/tools/ 1. jps 显示当前用户的所有java进程的PID 以及主类名 jps : 显示当前用户的所有java进程的PID 以及主类名 jps -v : 打印传递给 Java 虚拟机的参数(如-XX:+UnlockExperimentalVMOptions -XX:+UseZGC) jps -m : 打印传递给主类的参数 jps -l : 打印模块名以及包名 默认开启(UsePerfData),若加上-XX:-UsePerfData 则无法找到进程。 2. jstack 功能 jstack不仅会打印 线程 的栈轨迹、线程状态(BLOCKED)、持有的锁(locked…)以及正在请求的锁(waiting to lock …),而且还会分析出具体的 死锁 。 jstack pid : 查看线程情况 jstack -F pid : 正常输出不被响应时

close wait 导致的java web容器假死

蓝咒 提交于 2019-11-26 19:36:22
1.现象 线上tomcat或后台task java进程偶发性出现假死,完全没有规律 1.1 java环境 java -version 1.2 linux环境 // 查看操作系统版本信息 cat /proc/version // 查看操作系统内核信息 uname -a // 查看系统版本信息的命令 lsb_release -a 2.分析步骤 2.1 查看进程存活状态 ps -ef | grep java 查询到该进程的ID是 12635 ,监听的端口是 10061 ,后面会用到 2.2 查看该端口的监听情况 // 查看该tomcat服务监听的端口,并将结果输出至日志文件 netstat -an | grep 10061 >> netstat-sku.log // 查看前200行内容 head -n 200 netstat-sku.log 发现大量close wait,初步可以判断是close wait导致的假死 2.3 查看内存使用情况 // 查看内存使用情况 jmap -heap 12635 Eden Space 内存基本耗费完,但没有触发GC 2.4 查看线程状态 -F to force a thread dump. Use when jstack <pid> does not respond (process is hung) 强制线程转储。当jstack <pid

docker应用,后端服务出现OOM情况排查

僤鯓⒐⒋嵵緔 提交于 2019-11-26 19:36:12
参考: https://qingmu.io/2018/12/17/How-to-securely-limit-JVM-resources-in-a-container/#more 默认情况下,JVM的Max Heap Size是系统内存的1/4,假如我们系统是8G,那么JVM将的默认Heap≈2G。 # docker logs compose_cwtpro-back_1 Exception in thread "http-nio-8080-Acceptor-0" java.lang.OutOfMemoryError: GC overhead limit exceeded 28-Feb-2019 08:59:19.035 SEVERE [http-nio-8080-ClientPoller-0] org.apache.tomcat.util.net.NioEndpoint$Poller.events java.lang.OutOfMemoryError: GC overhead limit exceeded Exception in thread "http-nio-8080-exec-89" java.lang.OutOfMemoryError: GC overhead limit exceeded Exception in thread "http-nio-8080-exec

Does jmap force garbage collection when the live option is used?

给你一囗甜甜゛ 提交于 2019-11-26 19:35:49
问题 I've been experimenting with jmap -histo and jmap -dump today When run in this sequence jmap -dump:format=b,file=heap.1 [pid] jmap -dump:live,format=b,file=heap.2 [pid] jmap -dump:format=b,file=heap.3 [pid] heap.3 resembles heap.2 more than heap.1 . In particular, the "dead" objects that I'm interested in in heap.1 are absent from heap.3 . Seeing this, I started looking for documentation that would tell me what I should expect. The closest I managed to get was this discussion, where the

Core dump taken with gcore, jmap conversion to hprof file format fails with Error message

拜拜、爱过 提交于 2019-11-26 18:22:15
问题 We recently had one of our JVM's crash, leaving behind a core dump file produced by the gcore command. We want to have a look at the contents of the file and find out exactly what caused the crash. Using the jmap command you are supposed to be able to turn core dump files into files in the hprof file format, which you can then analyse using VisualVM and a number of other tools. I've tried this and get an error message. This was the command that I ran (on the same box that the crash took place

[总结]-第四章 虚拟机性能监控与故障处理工具

雨燕双飞 提交于 2019-11-26 18:18:16
[总结]-第四章 虚拟机性能监控与故障处理工具 进入JDK安装目录 cd $JAVA_HOME/bin ls 输出 appletviewer javah jjs jvisualvm schemagen extcheck javap jmap keytool serialver idlj javapackager jmc native2ascii servertool jar jcmd jps orbd tnameserv jarsigner jconsole jrunscript pack200 unpack200 java jdb jsadebugd policytool wsgen javac jdeps jstack rmic wsimport javadoc jhat jstat rmid xjc javafxpackager jinfo jstatd rmiregistry 工具命令 名称 主要作用 jps JVM Process Status Tool,显示指定系统内所有的HotSpot虚拟机进程 jstat JVM Statistics Monitoring Tool,用于收集HotSpot虚拟机各方面的运行数据 jinfo Configuration Info for Java,显示虚拟机配置信息 jmap Memory Map for Java

How to analyse the heap dump using jmap in java

大兔子大兔子 提交于 2019-11-26 18:01:49
问题 I am creating heap dump using below command: jmap -dump:file=DumpFile.txt <process-id> I have opened the generated file - DumpFile.txt but it is not in readable format. So please let me know how to analyze the data in the generated file. 回答1: You should use jmap -heap:format=b <process-id> without any paths. So it creates a *.bin file which you can open with jvisualvm.exe (same path as jmap). It's a great tool to open such dump files. 回答2: You can use jhat (Java Heap Analysis Tool) to read

How do you Force Garbage Collection from the Shell?

℡╲_俬逩灬. 提交于 2019-11-26 15:06:50
问题 So I am looking at a heap with jmap on a remote box and I want to force garbage collection on it. How do you do this without popping into jvisualvm or jconsole and friends? I know you shouldn't be in the practice of forcing garbage collection -- you should just figure out why the heap is big/growing. I also realize the System.GC() doesn't actually force garbage collection -- it just tells the GC that you'd like it to occur. Having said that is there a way to do this easily? Some command line

JVM异常

六眼飞鱼酱① 提交于 2019-11-25 22:25:51
分析系统堆栈 1.查看应用线程 jps -l 2.导出dump信息 jmap -dump:live,file=app.dump 6864 来源: oschina 链接: https://my.oschina.net/u/3126880/blog/3132226