1

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

DTK
  • 95
  • 1
  • 9
  • hprof [has been removed](https://bugs.openjdk.java.net/browse/JDK-8046661) in JDK 9, and is not supposed to work in later JDK versions. You may use [JDK Mission Control](https://www.oracle.com/java/technologies/jdk-mission-control.html) instead, or many of third party Java profilers, e.g. a lightweight yet powerful [async-profiler](https://github.com/jvm-profiling-tools/async-profiler/). – apangin Apr 13 '21 at 20:41
  • That explains a lot! Thank you! – DTK Apr 14 '21 at 11:49

1 Answers1

4

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/

cwittah
  • 349
  • 1
  • 3
  • 17