如何获取java heap dump

如何获取java heap dump
2010-06-25 12:43
C:/Program Files/Java/jdk1.6.0_20/bin>jmap
Usage:
jmap -histo <pid>
(to connect to running process and print histogram of java object heap
jmap -dump:<dump-options> <pid>
(to connect to running process and dump java heap)

dump-options:
format=b     binary default
file=<file> dump heap to <file>

Example:       jmap -dump:format=b,file=heap.bin <pid>


或者,运行 jconsole, 选择 MBeans -> com.sun.management -> HotSpotDiagnostic -> Operations -> dumpHeap 在参数p0中填写保存dump文件的路径,如果要使用Eclipse Memory Analyzer来分析则文件的后缀要为 hprof。点击dumpHeap按钮生成dump文件。


或者 在Eclipse Memory Analyzer中直接生成



或者,设置 jvm让其在out of memory的时候 自动生成dump文件: -XX:+HeapDumpOnOutOfMemoryError 或者 -XX:+HeapDumpOnCtrlBreak,更多设置见 http://wiki.eclipse.org/index.php/MemoryAnalyzer#Getting_a_Heap_Dump


附带一句,dump文件可以使用Eclipse Memory Analyzer
http://dev.eclipse.org/blogs/memoryanalyzer/2008/04/21/immortal-objects-or-how-to-find-memory-leaks/
http://wiki.eclipse.org/index.php/MemoryAnalyzer#Finding_Memory_Leaks

Finding Memory Leaks

Start by running the leak report to automatically check for memory leaks.
This blog details How to Find a Leaking Workbench Window.
The Memory Analyzer grew up at SAP. Back then, Krum blogged about Finding Memory Leaks with SAP Memory Analyzer. The content is still relevant!

Analyzing Java Collection Usage

Check out Krum's blog about Analyzing Java Collections Usage with Memory Analyzer. Also, Memory for Nothing looks unused collections and the memory kept alive.

Perm Space Issus

A good starting point is the blog The Unknown Generation: Perm by Andreas.
Also, Vedran has blogged some hints how to address Perm Space Issues.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值