1

With the basic knowledge of java 'hprof', I tried executing the below command as per 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 ?

Jean-François Savard
  • 20,626
  • 7
  • 49
  • 76
Aarish Ramesh
  • 6,745
  • 15
  • 60
  • 105

1 Answers1

2

You just need to remove the .class at the end of the class as Java by default will search for class files.

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

Jean-François Savard
  • 20,626
  • 7
  • 49
  • 76