jmap转换gcore的dump文件
- - 开源软件 - ITeye博客使用gdb生成gcore快照文件. sudo gdb -q --pid=4990
【此处省略乱七八糟的输出内容】. --pid后面跟着的是jvm的进程id. 这里调用命令生成gcore的dump文件. detach是用来断开与jvm的连接的. quit简单了,退出gdb模式. 用jmap转换gcore的dump文件变成hprof.
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
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
(gdb) generate-core-file
(gdb) detach
(gdb) quit
用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的快照信息。