jmap转换gcore的dump文件

找java进程

 

ps aux|grep java

yyy    4990  0.3  2.3 3098560 191312 ?      Sl   Aug29  16:11 /usr/xxx/jdk1.6.0_29/bin/java -Xms128m -Xmx768m -jar /usr/share/projectlibre/projectlibre.jar --silentlyFail true

 

 

使用gdb生成gcore快照文件

 

sudo gdb -q --pid=4990
【此处省略乱七八糟的输出内容】
......
0x00007ffc1672366b in pthread_join (threadid=140720663160576, thread_return=0x7fffe8470210) at pthread_join.c:92
92	pthread_join.c: No such file or directory.
(gdb) generate-core-file 
warning: target file /proc/4990/cmdline contained unexpected null characters
Saved corefile core.4990
(gdb) detach 
Detaching from program: /usr/xxx/jdk1.6.0_29/bin/java, process 4990
(gdb) quit

 

命令解释:
gdb -q --pid=4990
 
--pid后面跟着的是jvm的进程id
(gdb) generate-core-file 
 
这里调用命令生成gcore的dump文件
(gdb) detach 
 
detach是用来断开与jvm的连接的
(gdb) quit
 

quit简单了,退出gdb模式

用jmap转换gcore的dump文件变成hprof

sudo /usr/xxx/jdk1.6.0_29/bin/jmap -dump:format=b,file=heap.hprof /usr/xxx/jdk1.6.0_29/bin/java core.4990
Attaching to core core.4990 from executable /usr/xxx/jdk1.6.0_29/bin/java, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 20.4-b02
Dumping heap to heap.hprof ...
Finding object size using Printezis bits and skipping over...
Heap dump file created

 

 

接着就生成了heap.hprof这个文件

 

注意:jmap、java等指令必须是与启动4990进程一致的版本才可以成功转换,否则还是会有问题。

 

可以使用jvisualvm打开 heap.hprof查看jvm的快照信息。

 

参考文章:

  1. http://www.tuicool.com/articles/JbyyUr
  2. http://stackoverflow.com/questions/9981080/core-dump-taken-with-gcore-jmap-conversion-to-hprof-file-format-fails-with-erro
  3. http://blog.163.com/yandong_8212/blog/static/1321539142010108112559362/


已有 0 人发表留言,猛击->> 这里<<-参与讨论


ITeye推荐
  • —软件人才免语言低担保 赴美带薪读研!—



你可能感兴趣的:(dump,JMAP,gcore)