概述
JavaCore文件
又称为ThreadDump,保存的是Java应用各线程在某一时刻的运行的位置,即JVM执行到哪一个类、哪一个方法、哪一个行上。
它是一个文本文件,打开后可以看到每一个线程的执行栈,以stack trace的显示。
通过对ThreadDump文件的分析可以得到应用是否“卡”在某一线程上,即在某一线程运行的时间太长。
HeapDump文件
二进制文件,它保存了某一时刻JVM堆中对象使用情况。
作用就是分析系统中是否存在内存溢出的情况。
JavaCore(ThreadDump)生成方法
方法1: Getting a Thread Dump Using jstack
In JDK 1.6 and higher, it is possible to get a thread dump on MS Windows using jstack.
Use PID via jps to check the PID of the currently running Java application process.
Use the extracted PID as the parameter of jstack to obtain a thread dump.
方法2: A Thread Dump Using jVisualVM
Generate a thread dump by using a program such as jVisualVM.
The task on the left indicates the list of currently running processes.
Click on the process for which you want the information,
and select the thread tab to check the thread information in real time.
Click the Thread Dump button on the top right corner to get the thread dump file.
方法3:Generating in a Linux Terminal
Obtain the process pid by using ps -ef command to check the pid of the
currently running Java process.
Use the extracted pid as the parameter of kill –SIGQUIT(3) to obtain a thread dump.
例如:
# 查询进程
# ps -ef | grep java
user 3186 5872 0 18:40 pts/0 00:00:00 grep java
root 7760 1 0 Oct27 ? 00:02:27 /usr/bin/java -server -XX:PermSize=64M -XX:MaxPermSize=128m -classpath :/usr/local/tomcat8090/bin/bootstrap.jar org.apache.catalina.startup.Bootstrap start
# 执行kill命令
# kill -3 7760
ThreadDump文件格式
2018-10-09 11:27:02
Full thread dump Java HotSpot(TM) 64-Bit Server VM (24.80-b11 mixed mode):
"elasticsearch[Norman Osborn][management][T#2]" daemon prio=6 tid=0x0000000020d7f800 nid=0x434 waiting on condition [0x000000003446e000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000ca2f0828> (a org.elasticsearch.common.util.concurrent.EsExecutors$ExecutorScalingQueue)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
at java.util.concurrent.LinkedTransferQueue.awaitMatch(LinkedTransferQueue.java:731)
at java.util.concurrent.LinkedTransferQueue.xfer(LinkedTransferQueue.java:644)
at java.util.concurrent.LinkedTransferQueue.poll(LinkedTransferQueue.java:1145)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Locked ownable synchronizers:
- None
"VM Thread" prio=10 tid=0x00000000099db000 nid=0xe64 runnable
"GC task thread#0 (ParallelGC)" prio=6 tid=0x00000000025ce000 nid=0x1c18 runnable
"GC task thread#1 (ParallelGC)" prio=6 tid=0x00000000025cf800 nid=0x10cc runnable
"GC task thread#2 (ParallelGC)" prio=6 tid=0x00000000025d1800 nid=0xbcc runnable
"GC task thread#3 (ParallelGC)" prio=6 tid=0x00000000025d3000 nid=0x1ee4 runnable
"VM Periodic Task Thread" prio=10 tid=0x000000000b26b000 nid=0x194c waiting on condition
JNI global references: 46038
HeapDump 生成方式
方法1:Using jVisualVM
方法2:jvm 参数
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/log/
最后
以上就是怕孤单树叶为你收集整理的Javacore和Heapdump生成和获取(1)的全部内容,希望文章能够帮你解决Javacore和Heapdump生成和获取(1)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复