javaperformanceprofilehprof

Java Could not find agent library hprof on the library path


I was trying to profile CPU usage in my code and discovered the built-in hprof. https://docs.oracle.com/javase/8/docs/technotes/samples/hprof.html

However, as I tested I got the following error:

javac -J-agentlib:hprof=cpu=samples Main.java Error occurred during initialization of VM Could not find agent library hprof on the library path, with error: Can't find dependent libraries

I believe I am having a path issue, however, I have no clue of where this library is located to try adding to the path, I am using the jdk-15.0.2.

Does anyone have an idea of what could I try to find the exact location? Or any other alternative/Visual Studio Code extension to profile a java code?

Thanks a lot


Solution

  • Looks like HPROF was removed in JDK 9. Here's some alternatives: https://www.infoq.com/news/2015/12/OpenJDK-9-removal-of-HPROF-jhat/