Dev2Dev论坛

 找回密码
 注册
搜索
查看: 83|回复: 0

利用 Java dump 进行 JVM 故障诊断 [复制链接]

Rank: 1

robot 发表于 2011-9-9 23:30:09 |显示全部楼层

Windows 平台

 

如果是用控制台启动的程序,直接使用

Ctrl-Break

Linux 平台

 

如果是用控制台启动的程序,直接使用

Ctrl-\

例如:

class Test{
 
        public static void main(String args[]) throws Exception {
                System.out.println("Hello");
 
                while(true){
                        java.lang.Thread.sleep(1000);
                }
        }
 
}
lijun@john:~$ javac Test.java
lijun@john:~$ java Test

Thread Dump 出来的日志:

2011-09-09 20:29:29
Full thread dump Java HotSpot(TM) Server VM (20.1-b02 mixed mode):

"Low Memory Detector" daemon prio=10 tid=0x72214400 nid=0x3249 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" daemon prio=10 tid=0x72212800 nid=0x3248 waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" daemon prio=10 tid=0x72210400 nid=0x3247 waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x7220ec00 nid=0x3246 waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=10 tid=0x72200800 nid=0x3245 in Object.wait() [0x723d1000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on  (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
	- locked  (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
	at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0x08785000 nid=0x3244 in Object.wait() [0x72422000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on  (a java.lang.ref.Reference$Lock)
	at java.lang.Object.wait(Object.java:485)
	at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
	- locked  (a java.lang.ref.Reference$Lock)

"main" prio=10 tid=0x08705800 nid=0x3240 waiting on condition [0xb6a82000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
	at java.lang.Thread.sleep(Native Method)
	at Test.main(Test.java:7)

"VM Thread" prio=10 tid=0x08781400 nid=0x3243 runnable 

"GC task thread#0 (ParallelGC)" prio=10 tid=0x0870cc00 nid=0x3241 runnable 

"GC task thread#1 (ParallelGC)" prio=10 tid=0x0870e000 nid=0x3242 runnable 

"VM Periodic Task Thread" prio=10 tid=0x72216000 nid=0x324a waiting on condition 

JNI global references: 882

Heap
 PSYoungGen      total 18176K, used 312K [0x9f440000, 0xa0880000, 0xb38e0000)
  eden space 15616K, 2% used [0x9f440000,0x9f48e158,0xa0380000)
  from space 2560K, 0% used [0xa0600000,0xa0600000,0xa0880000)
  to   space 2560K, 0% used [0xa0380000,0xa0380000,0xa0600000)
 PSOldGen        total 41600K, used 0K [0x76ae0000, 0x79380000, 0x9f440000)
  object space 41600K, 0% used [0x76ae0000,0x76ae0000,0x79380000)
 PSPermGen       total 16384K, used 1744K [0x72ae0000, 0x73ae0000, 0x76ae0000)
  object space 16384K, 10% used [0x72ae0000,0x72c942d8,0x73ae0000)

如果JVM运行在后台进程,则向改进成发送QUIT信号即可:

kill -QUIT process_id

参考文章:http://www.ibm.com/developerworks/cn/websphere/library/techarticles/0903_suipf_javadump/


links:http://www.kissrain.org/2011-09-09-364.html
您需要登录后才可以回帖 登录 | 注册

Archiver|Dev2Dev

GMT+8, 2012-5-21 12:40 , Processed in 0.262911 second(s), 12 queries .

Powered by Discuz! X2 Licensed

© 2001-2011 Comsenz Inc.

回顶部