JMAP

启动一个最简单的Java main程序时有多少个线程被创建

天大地大妈咪最大 提交于 2019-11-29 18:37:50
 在java中,启动一个简单的main程序,并不是只是单单创建了一个main线程而已,JVM会自动创建一些辅助用的线程,主要有以下几个:   Attach Listener:Attach Listener线程是负责接收到外部的命令,而对该命令进行执行的并且吧结果返回给发送者。通常我们会用一些命令去要求jvm给我们一些反 馈信 息,如:java -version、jmap、jstack等等。如果该线程在jvm启动的时候没有初始化,那么,则会在用户第一次执行jvm命令时,得到启动。   Signal Dispatcher:前面我们提到第一个Attach Listener线程的职责是接收外部jvm命令,当命令接收成功后,会交给signal dispather线程去进行分发到各个不同的模块处理命令,并且返回处理结果。signal dispather线程也是在第一次接收外部jvm命令时,进行初始化工作。   Finalizer:这个线程也是在main线程之后创建的,其优先级为10,主要用于在垃圾收集前,调用对象的finalize()方法;   Reference Handler:VM在创建main线程后就创建Reference Handler线程,其优先级最高,为10,它主要用于处理引用对象本身(软引用、弱引用、虚引用)的垃圾回收问题。 以上这部分内容引用自 http://ifeve.com

综合技术----线上环境内存暴涨或者CPU暴增问题排查

三世轮回 提交于 2019-11-29 06:47:56
最近线上环境系统经常出现内存暴涨的现象,前段时间经常出现数据库服务器CPU暴增(经常100%)的情况。经过逐步排查,最终解决问题,先将解决过程记录下来。 解决内存暴涨步骤 1.排查报错日志 运维反应内存涨的快,我们第一反应肯定是拿到日志,进行分析,发现很多GC,初步断定内存泄漏 2.查看tomcat线程 命令:ps -ef|grep tomcat 3.查看该pid下线程占用情况 命令:top -Hp [pid] 会发现前几个线程(eg:pid1、pid2等)占用资源比较多,几乎占用了整个cpu资源,将pid1、pid2等转换成16进制pid1_16、pid2_16. 3.1 线上问题比较紧急时,可以先杀掉这些线程,然后在逐步排查 命令:kill -9 [pid] 4.下载当前java线程栈,我公司路径/usr/java/jdk1.7.0_80/bin/jstack -l [pid] >/webtv/gc.txt 5.分析第4步中的线程栈,排查步骤3中的pid1_16、pid2_16等线程具体原因 6.如果前面的步骤还不能解决问题,则进行如下一步,dump该pid下java堆数据,/usr/java/jdk1.7.0_80/bin/jmap -dump:format=b,file=/webtv/gc.hprof [pid 7.使用MAT工具(自行百度下载)加载如上堆文件,然后进行分析

How to take a heap dump in windows with minimum downtime?

荒凉一梦 提交于 2019-11-29 02:40:42
I want to figure out why JVM heap usage on Elasticsearch node is staying consistently above 80%. In order to do this, I take a heap dump by running jmap.exe -heap:format=b 5348 (5348 is the Process ID). Then I can analyze the dump with VisualVM. The problem is that jmap pauses the JVM while taking the dump, so the node is basically offline for around 5 minutes. This article suggests a faster approach that relies on taking coredump with gdb on Linux. I already tried WinDbg, which created a core dump, but I couldn't use it in VisualVM. Is there a similar approach for Windows? How one can take

Is a JVM stopped while executing jmap?

本小妞迷上赌 提交于 2019-11-29 01:48:54
Does my java application continue running while jmap is taking its memory dump? Your application is stopped. The only practical way to get an accurate heap dump would be to stop all application activity while the dump is being created. Whether this is a "brief" pause or a "long" pause depends on how much is dumped. If you use "-dump" then you will dump the entire heap, including unreachable objects. If you use "-dump:live" you will only dump reachable objects ... but that also entails (at least) marking the heap to figure out which objects are reachable. But if you are dumping a gigabyte sized

JVM内存监控:visualVM jconsole jstatd jmap

*爱你&永不变心* 提交于 2019-11-29 00:32:29
转载的一篇文章,但是对文章做了一些补充,以便看到这篇文章的同学能配置成功。 本文是亲自测试的详细配置过程, 不是转载而且linux下不需修改/etc/hosts文件 由于在建项目的需要,监控tomcat的内存使用,检查内存泄漏的情况。其实JDK自身已经提供了很多工具,都在J AVA_HOME/bin/ 目录下:jvisualvm、jconsole、jstatd、jmap等等,以下为试验的环境配置: client: vista、jdk1.6.0_18 server: linux、jdk1.6.0_02、tomcat6、IP:192.168.8.7 主要从下面三个方面描述: jmap (Memory Map) JVM内存对象打印工具 jstatd配置 Tomcat配置JMX 一、用jmap获取数据 JAVA_HOME/bin/jmap -histo PID JAVA_HOME/bin/jmap -histo PID >hismem.txt 显示信息包括Java类、类实例对象数量、在内存中占有量的大小以及类的完整包名。 //将JVM内存堆的信息dump成为一个二进制文件,可供jstat、Eclipse MAT内存分析工具来使用 JAVA_HOME/bin/jmap -dump:format=b,file=heap.bin PID Eclipse MAT的分析工具: http://www

线上应用故障排查之二:高内存占用

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 00:31:33
搞Java开发的,经常会碰到下面两种异常: 1、java.lang.OutOfMemoryError: PermGen space 2、java.lang.OutOfMemoryError: Java heap space 要详细解释这两种异常,需要简单重提下Java内存模型。 Java内存模型 是描述Java程序中各变量(实例域、静态域和数组元素)之间的关系,以及在实际计算机系统中将变量存储到内存和从内存取出变量这样的低层细节。 在Java虚拟机中,内存分为三个代:新生代( New )、老生代( Old )、永久代( Perm )。 (1)新生代New:新建的对象都存放这里 (2)老生代Old:存放从新生代New中迁移过来的生命周期较久的对象。新生代New和老生代Old共同组成了堆内存。 (3)永久代Perm:是非堆内存的组成部分。主要存放加载的Class类级对象如class本身,method,field等等。 如果出现java.lang.OutOfMemoryError: Java heap space异常,说明Java虚拟机的堆内存不够。原因有二: (1)Java虚拟机的堆内存设置不够,可以通过参数-Xms、-Xmx来调整。 (2)代码中创建了大量大对象,并且长时间不能被垃圾收集器收集(存在被引用)。 如果出现java.lang.OutOfMemoryError:

jmap -histo pid 输出的[C [B [I [S methodKlass constantPoolKlass含义

余生长醉 提交于 2019-11-28 22:04:00
JMAP 输出 [hadoop@DEV logs]$ jmap -histo 24527 | head -30 num #instances #bytes class name ---------------------------------------------- 1: 31939 98883072 [C 2: 8594 9461992 [B 3: 30326 4256232 <constMethodKlass> 4: 30326 3892592 <methodKlass> 5: 2719 3226344 <constantPoolKlass> 6: 2450 1948704 <constantPoolCacheKlass> 7: 2719 1869200 <instanceKlassKlass> 8: 27599 662376 java.lang.String 9: 836 442968 <methodDataKlass> 10: 8215 394320 org.apache.tomcat.util.buf.ByteChunk 11: 3012 366720 java.lang.Class 12: 11257 360224 java.util.HashMap$Entry 13: 3417 273360 java.lang.reflect.Method 14: 6763

What do those strange class names in a java heap dump mean?

怎甘沉沦 提交于 2019-11-28 17:12:57
I'm trying to track down a memory leak in a java process, using jmap and jhat . Every time I do this I see those weird notation for specific object types, like [S for string arrays and [C for Character arrays. I never remember what means what, and it's very hard to google this stuff. ( EDIT : to prove my point, it turns out that [S is array of short and [C is array of char.) Anyone care to make a table listing all the different class names and what they mean? Or point me to such table? Specifically I'd like to know what [Ljava.lang.Object; means. kdgregory You'll find the complete list

How to take a heap dump in windows with minimum downtime?

梦想与她 提交于 2019-11-27 21:59:00
问题 I want to figure out why JVM heap usage on Elasticsearch node is staying consistently above 80%. In order to do this, I take a heap dump by running jmap.exe -heap:format=b 5348 (5348 is the Process ID). Then I can analyze the dump with VisualVM. The problem is that jmap pauses the JVM while taking the dump, so the node is basically offline for around 5 minutes. This article suggests a faster approach that relies on taking coredump with gdb on Linux. I already tried WinDbg, which created a

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

会有一股神秘感。 提交于 2019-11-27 18:46:21
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 comments from briand and alanb imply that in practice I can expect this GC to occur when I use the live