分析离线 Java 堆转储 (.hprof) 的工具或技巧

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4347518/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 16:18:43  来源:igfitidea点击:

Tool or tricks to analyze offline Java heap dumps (.hprof)

javavisualvmheap-dump

提问by user331465

Are there any tools that allow offline analysis (including summary/sorting/sifting) of an .hprof file? Or can you run VisualVM, hat etc in batch mode?

是否有任何工具允许对 .hprof 文件进行离线分析(包括汇总/排序/筛选)?或者你可以在批处理模式下运行 VisualVM、hat 等吗?

I'm interested in something that can take an input .hprof file, crunch it and generate reports.

我对可以输入 .hprof 文件、处理它并生成报告的东西感兴趣。

I assume you would need to pass in a bunch of options to configure the report, so if you know any helpful tips, please weigh in.

我假设您需要传入一堆选项来配置报告,所以如果您知道任何有用的提示,请权衡。

Preferably scriptable so I could run a bunch at once.

最好是可编写脚本的,这样我就可以一次运行一堆。

采纳答案by user85155

Eclipse Memory Analyzerdoes everything you need.

Eclipse Memory Analyzer可以满足您的一切需求。

回答by Peter Lawrey

Can you use jmap -histo ? What sort of report are you looking to extract?

你可以使用 jmap -histo 吗?您希望提取什么样的报告?

回答by james

hard to beat yourkit java profiler. It costs money, but it is worth every penny.

很难击败yourkit java profiler。它要花钱,但每一分钱都是值得的。

回答by kohlerm

回答by robbin

JDK6 comes with jhat which parses and creates an html report.

JDK6 带有 jhat,它解析并创建一个 html 报告。

http://docs.oracle.com/javase/6/docs/technotes/tools/share/jhat.html

http://docs.oracle.com/javase/6/docs/technotes/tools/share/jhat.html

回答by user2426263

You can use jhatto parse/navigate the memory dump of an .hproffile.

您可以使用jhat来解析/导航.hprof文件的内存转储。

$ jhat heapdump.hprof
Reading from heapdump.hprof...

Started HTTP server on port 7000
Server is ready.

The tool comes with the JDK.

该工具随 JDK 一起提供。