HPjmeter-like graphical tool to view -agentlib:hprof profiling output

六月ゝ 毕业季﹏ 提交于 2019-11-28 20:50:09

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.

sleske

For viewing and analyzing the output of hprof=samples or hprof=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

java -jar PerfAnal.jar hprof.java.txt

You may need to fiddle with -Xmx for large hprof files.

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.

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

jmap -dump:format=b,file=<filename>.hprof <jvm_pid> 

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

-javaagent:<path>/shiftone-jrat.jar

This will generate a directory with the profile captured by the tool. Then, execute

 java -jar shiftone-jrat.jar

And open the trace. Even been a simple tool, I think it could be useful.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!