用于查看 -agentlib:hprof 分析输出的类似 HPjmeter 的图形工具
有哪些工具可用于查看内置 JVM 分析器的输出? 例如,我使用以下命令启动 JVM:
-agentlib:hprof=cpu=times,thread=y,cutoff=0,format=a,file=someFile.hprof.txt
这会生成 hprof(“JAVA PROFILE 1.0.1”)格式的输出。
我过去曾成功使用 HPjmeter 查看这些输出文件以合理的方式。 然而,无论出于何种原因,使用当前版本的 Sun JVM 生成的文件无法在当前版本的 HPjmeter 中加载:(
java.lang.NullPointerException
at com.hp.jmeter.f.jb.a(Unknown Source)
at com.hp.jmeter.f.a.a(Unknown Source)
at com.hp.c.a.j.z.run(Unknown Source)
Exception in thread "HPeprofDataFileReaderThread" java.lang.AssertionError: null pointer exception from loader
at com.hp.jmeter.f.a.a(Unknown Source)
at com.hp.c.a.j.z.run(Unknown Source)
为什么他们会混淆免费产品的字节码?!)
由此产生了两个问题
- :知道 HPjmeter 错误的原因吗? (编辑:是的 - 见下文)
- 还有哪些其他工具可以读取 hprof 文件? 为什么没有来自 Sun 的信息(有吗)?
我知道 Eclipse TPTP 和其他工具可以动态监控 JVMTI 数据,但我需要一个解决方案由于部署的计算机仅安装了 JRE(而不是 JDK),因此可以在事后处理生成的 hprof 文件。
编辑:一位非常有帮助的 HPjmeter 开发人员回复了我的 HP ITRC 论坛上的问题表明,需要暂时将 heap=dump
包含在 -agentlib
选项中,直到修复 HPjmeter 中的错误为止。 这些信息使 HPjmeter 再次变得可行,但我仍然会保留这个问题,看看是否有人知道任何其他工具。
编辑:从 HPjmeter 4.0.00 版(2009 年 5 月发布)开始,此错误已得到修复。
What tools are available to view the output of the built-in JVM profiler? For example, I'm starting my JVM with:
-agentlib:hprof=cpu=times,thread=y,cutoff=0,format=a,file=someFile.hprof.txt
This generates output in the hprof ("JAVA PROFILE 1.0.1") format.
I have had success in the past using HPjmeter to view these output files in a reasonable way. However, for whatever reason the files that are generated using the current version of the Sun JVM fail to load in the current version of HPjmeter:
java.lang.NullPointerException
at com.hp.jmeter.f.jb.a(Unknown Source)
at com.hp.jmeter.f.a.a(Unknown Source)
at com.hp.c.a.j.z.run(Unknown Source)
Exception in thread "HPeprofDataFileReaderThread" java.lang.AssertionError: null pointer exception from loader
at com.hp.jmeter.f.a.a(Unknown Source)
at com.hp.c.a.j.z.run(Unknown Source)
(Why would they obfuscate the bytecode for a free product?!)
Two questions arise from this:
- Does anyone know the cause of this HPjmeter error? (EDIT: Yes--see below)
- What other tools exist to read hprof files? And why are there none from Sun (are there)?
I know the Eclipse TPTP and other tools can monitor JVMTI data on the fly, but I need a solution that can process the generated hprof files after the fact since the deployed machine only has a JRE (not a JDK) intalled.
EDIT: A very helpful HPjmeter developer replied to my question on an HP ITRC forum indicating that heap=dump
needs to be included in the -agentlib
options temporarily until a bug in HPjmeter is fixed. This information makes HPjmeter viable again, but I will still leave the question open to see if anyone knows of any other tools.
EDIT: As of version 4.0.00 of HPjmeter (available 05/2009) this bug has been fixed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您的套件 Java Profiler 能够读取 hprof 快照(我不确定是否仅用于内存分析或 CPU )。 它不是免费的,但它是迄今为止我用过的最好的 Java 分析器。 它以清晰、直观的方式呈现结果,并且在大数据集上表现良好。 文档也非常好。
Your Kit Java Profiler is able to read hprof snapshots (I am not sure if only for memory profiling or for CPU as well). It is not free but is by far the best java profiler I ever used. It presents the results in a clear, intuitive way and performs well on large data sets. The documentation is also pretty good.
为了查看和分析
hprof=samples
或hprof=cpu
的输出,我使用了 PerfAnal,效果良好。 GUI 有点简陋,但非常有用。PerfAnal 是免费下载的(GPL,最初是《Linux 上的 Java 编程》一书中的示例项目)。
请参阅这篇文章:
http://www.oracle.com/technetwork/articles /javase/perfanal-137231.html
了解更多信息和下载。
通常你可以只运行
你可能需要摆弄 -Xmx 对于大型 hprof 文件。
For viewing and analyzing the output of
hprof=samples
orhprof=cpu
I have used PerfAnal with good results. The GUI is a bit spartan, but very useful.PerfAnal is a free download (GPL, originally an example project in the book Java Programming on Linux).
See this article:
http://www.oracle.com/technetwork/articles/javase/perfanal-137231.html
for more information and the download.
Normally you can just run
You may need to fiddle with -Xmx for large hprof files.
我不是 100% 确定它会起作用(听起来好像会),而且我不确定它会以您想要的格式显示它......但是您是否考虑过 VisualVM?
我相信它会打开生成的文件。
I am not 100% sure it'll work (it sounds like it will) and I am not sure it'll show it in the format you want... but have you thought about the VisualVM?
I believe it'll open up the resulting file.
我一直在使用 Eclipse Memory Analyzer 成功分析不同的性能问题。 首先,按照项目网页中的说明在 Eclipse 中安装该工具。
之后,您可以创建一个转储文件,知道要分析的jvm的pid
,然后只需在eclipse中导入.hprof文件即可。 它有一些自动报告,试图(对我来说它们通常不起作用)指出哪些可能是可能的问题。
编辑:
回答评论:你是对的,它更像是Java的泄漏查找器。 对于性能问题,我在小型项目中使用了JRat。 它显示每个方法消耗的时间、调用方法的次数、调用的层次结构等。唯一的问题是,据我所知,它不支持 .hprof 文件。 要使用它,您需要执行添加 VM 参数的程序,
这将生成一个包含该工具捕获的配置文件的目录。 然后,执行
并打开跟踪。 即使是一个简单的工具,我认为它也很有用。
I have been using Eclipse Memory Analyzer for analyzing different performance problems successfully. First of all, install the tool as described in the project webpage in Eclipse.
After that, you can create a dump file knowing the pid of the jvm to be analyzed
Then just import the .hprof file in eclipse. It has some automatic reports that try (for me they usually do not work) to point out which could be the possible problems.
Edit:
Answering the comment: You are right, it is more like a leak finder for Java. For performance problems, I have played with JRat for small projects. It shows time comsumed per method, number of times a method is called, hierarchy of calls, etc. The only problem is that as far as I know, it does not support .hprof files. To use it, yo need to execute your program adding a VM argument
This will generate a directory with the profile captured by the tool. Then, execute
And open the trace. Even been a simple tool, I think it could be useful.