JMAP

jmap - Does histo & heap operation bring overhead to jvm?

你。 提交于 2019-12-12 09:49:41
问题 As the title states, how much overhead does jmap -histo and jmap -heap bring to a jvm respectively? If a memory sensitive Java process is at the edge of OutOfMemory (e.g around 96% of heap is full, and can't be cleared by full gc), is it possible for one of the operations to bring the jvm to OutOfMemory? 回答1: jmap -histo and jmap -heap work differently: jmap -histo uses Dynamic Attach Mechanism, and jmap -heap works through HotSpot Serviceability Agent. The difference is described here.

I found what kind of objects are causing a memory leak, now what?

半世苍凉 提交于 2019-12-11 23:49:21
问题 Using the jmap -histo command on a running process, every 30 minutes or so, I found one kind of object that is obviously a memory leak (in a desktop app). The object responsible for the leak ( I.e. the only kind of object whose number of instances grows over time, and by a huge amount) is int[] . I suspect BufferedImage to be the culprit but I'm not sure about that (I took great care about flushing/nullifying BufferedImage s but I still think that's where the leak hangs). However I'm also

blazesds consuming huge memory

半腔热情 提交于 2019-12-11 18:48:14
问题 BlazeDS 4 is used to communicate with Flex4.6. When flex client invokes a remote call on blazeds server, server returns an arrayList containing POJOs. Assuming each POJO mem size is 12 bytes, I am expecting the arrayList size to be 12*number of elements. However, I find that somewhere in blazeds, it is compounded multiple times. Assuming I add 200000 POJOs into the array list, I am expecting its size to be ~2MB. But, I could see through profilers, that JVM shoots up N times of original size

JVM性能调优监控工具jps、jstack、jmap、jhat、jstat、hprof使用详解

醉酒当歌 提交于 2019-12-10 15:41:17
现实企业级Java开发中,有时候我们会碰到下面这些问题: OutOfMemoryError,内存不足 内存泄露 线程死锁 锁争用(Lock Contention) Java进程消耗CPU过高 ...... 这些问题在日常开发中可能被很多人忽视(比如有的人遇到上面的问题只是重启服务器或者调大内存,而不会深究问题根源),但能够理解并解决这些问题是Java程序员进阶的必备要求。本文将对一些常用的JVM性能调优监控工具进行介绍,希望能起抛砖引玉之用。本文参考了网上很多资料,难以一一列举,在此对这些资料的作者表示感谢!关于JVM性能调优相关的资料,请参考文末。 A、 jps(Java Virtual Machine Process Status Tool) jps主要用来输出JVM中运行的进程状态信息。语法格式如下: 1 jps [options] [hostid] 如果不指定hostid就默认为当前主机或服务器。 命令行参数选项说明如下: 1 -q 不输出类名、Jar名和传入main方法的参数 2 -m 输出传入main方法的参数 3 -l 输出main类或Jar的全限名 4 - v 输出传入JVM的参数 比如下面: 1 root @ubuntu :/ # jps -m -l 2 2458 org.artifactory.standalone.main.Main /usr/ local

学习-JVM命令

谁说胖子不能爱 提交于 2019-12-10 12:22:19
jstat jstat (JVM statistics Monitoring)是用于监视虚拟机运行时状态信息的命令,它可以显示出虚拟机进程中的类装载、内存、垃圾收集、JIT编译等运行数据。 格式: jstat [option] LVMID [interval] [count] 参数: [option] : 操作参数 class : class loader的行为统计 compiler : HotSpt JIT编译器行为统计 gc : 垃圾回收堆的行为统计 gccapacity : 各个垃圾回收代容量(young,old,perm)和他们相应的空间统计 gcutil : 垃圾回收统计概述 gccause : 垃圾收集统计概述(同-gcutil),附加最近两次垃圾回收事件的原因 gcnew : 新生代行为统计 gcnewcapacity : 新生代与其相应的内存空间的统计 gcold : 年老代和永生代行为统计 gcoldcapacity : 年老代行为统计 gcpermcapacity : 永生代行为统计 printcompilation : HotSpot编译方法统计 LVMID : 本地虚拟机进程ID [interval] : 连续输出的时间间隔 [count] : 连续输出的次数 option 参数详解 -class 监视类装载、卸载数量、总空间以及耗费的时间 $ jstat

聊聊openjdk的jhsdb工具

China☆狼群 提交于 2019-12-09 22:23:44
序 本文主要研究一下openjdk的jhsdb工具 sa-jdi.jar export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home" chmod +x $JAVA_HOME/lib/sa-jdi.jar java -cp $JAVA_HOME/lib/sa-jdi.jar sun.jvm.hotspot.HSDB java -cp $JAVA_HOME/lib/sa-jdi.jar sun.jvm.hotspot.CLHSDB 在java9之前,JAVA_HOME/lib目录下有个sa-jdi.jar,可以通过如上命令启动HSDB( 图形界面 )及CLHSDB( 命令行 ) sa-jdi.jar中的sa的全称为Serviceability Agent,它之前是sun公司提供的一个用于协助调试HotSpot的组件,而HSDB便是使用Serviceability Agent来实现的 HSDB就是HotSpot Debugger的简称,由于Serviceability Agent在使用的时候会先attach进程,然后暂停进程进行snapshot,最后deattach进程( 进程恢复运行 ),所以在使用HSDB时要注意 jhsdb / # jhsdb clhsdb command

Mat can't open the dump file

被刻印的时光 ゝ 提交于 2019-12-07 11:55:24
问题 My jmap command is sudo -u flume /usr/java/jdk1.8.0_60/bin/jmap -F -dump:format=b,file=heap.hprof pid , But eclips mat can't open the dump file,and throw an exception. java.lang.NullPointerException at org.eclipse.mat.hprof.HprofParserHandlerImpl.resolveClassHierarchy(HprofParserHandlerImpl.java:587) at org.eclipse.mat.hprof.Pass2Parser.readInstanceDump(Pass2Parser.java:205) at org.eclipse.mat.hprof.Pass2Parser.readDumpSegments(Pass2Parser.java:159) at org.eclipse.mat.hprof.Pass2Parser.read

问题排查: spring kafka memory leak

你。 提交于 2019-12-07 09:41:12
现象 : 某个服务上线后,发现运行几天时间后,就没有响应了,也没有日志输出。之前的日志里面也没有任何异常。 猜测 : 进程也在,nginx等日志都正常,数据库也正常,怀疑就是服务有内存泄露。 排查思路 1. 生产环境不能影响正常服务,出现问题后,运维第一时间做了重启,现场就没了。然后用写了shell先定时重启(多台暂不间断提供服务)。 2. 接下来,就使用jmap看内存的对象数量了,总体来时只增不减的就是有问题的。同时,也做了个单独的测试环境,运行起来服务,准备重现问题。 3. 以下以重现的测试环境为例,首先找到进程号(假设是1302) (1) 使用 jmap -heap 1302 先看一下堆的情况 Attaching to process ID 1302, please wait... Debugger attached successfully. Server compiler detected. JVM version is 25.131-b11 using thread-local object allocation. Parallel GC with 8 thread(s) Heap Configuration: MinHeapFreeRatio = 0 MaxHeapFreeRatio = 100 MaxHeapSize = 4164943872 (3972.0MB)

日常 - 从 OutOfMemoryError 引发的思考

一世执手 提交于 2019-12-06 05:12:10
观看视频学习如何引发 OOM 和排查问题的过程, 视频 。 通过这个视频的学习了解了不少 JVM 的知识以及 debug 的方法,记录如下。 问题 常见的 OutOfMemoryError 有三类: java.lang.OutOfMemoryError: Java heap space 堆空间 java.lang.OutOfMemoryError: Java metaspace 元空间 java.lang.OutOfMemoryError: Java perm gen 永久代 步骤 实现 OOM 创建一个 OOM.java 文件,内容如下,由于全程将在命令行窗口执行 java 文件,虽然文件处于项目包中,但是添加包名会在命令行下编译错误,所以不添加: import java.util.HashMap; import java.util.Map; public class OOM { public static void main(String[] args) { Map cache = new HashMap(); for (int i = 0; i < 128; i++) { cache.put(i, new byte[1024 * 1024]); } } } 此时使用 javac 命令编译: javac OOM.java ,会出现 warning,原因是 Map 没有使用泛型

Jmap heap dump, does it include young generation?

无人久伴 提交于 2019-12-06 03:46:48
问题 Quick question Does the jmap heap dump include only the old generation, or also the young generation ? Long explanation I have 2 heap dump ( jmap -heap:format=b 9999 ) : one of my server with no load (no HTTP request) one while working 50% CPU, a high load (benchmarking) Now, the first dump shows a heap size bigger than the second (which I thought was weird). Could that be because the Young generation (at high load) is changing often because the Garbage collector is running often (yes, the