简体   繁体   English

如何使用Java堆探查器(HPROF)

[英]How to use java heap profilers (HPROF)

With the basic knowledge of java 'hprof', I tried executing the below command as per oracle docs 具有Java'hprof'的基本知识,我尝试按照oracle docs执行以下命令

java -agentlib:hprof Hello.class

But i get the below error instead of the profiling information 但是我得到以下错误而不是分析信息

Caused by: java.lang.ClassNotFoundException: Hello.class
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

Can someone illustrate on how should hprof be used properly so as to get the profiling information ? 有人可以说明如何正确使用hprof以获得配置信息吗?

You just need to remove the .class at the end of the class as Java by default will search for class files. 您只需要删除.class末尾的.class ,因为Java默认情况下会搜索class文件。

java -agentlib:hprof Hello

However, to get the heap allocation profile you need to add some parameters... 但是,要获取堆分配配置文件,您需要添加一些参数...

java -agentlib:hprof=heap=sites Hello

For more information type 有关更多信息,请键入

java -agentlib:hprof=help

And visit http://docs.oracle.com/javase/8/docs/technotes/samples/hprof.html 并访问http://docs.oracle.com/javase/8/docs/technotes/samples/hprof.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM