Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using VisualVM with IntelliJ

I'm trying to use VisualVM with IntelliJ to profile a Java application. I have the VisualVM Launcher plugin installed inside of IntelliJ. I press the play button with the orange circle in IntelliJ that launches VisualVM and opens the process when I start the run. However, when I try to profile the CPU, it doesn't seem to profile the methods in my program. I've tried with several different programs and can't seem to get any of them to work with VisualVM. This is what VisualVM looks like this:

enter image description here

The profiler seems to think that the total time is 857 ms or 6.21 ms when in reality my program takes about a minute to run. It seems to be capturing "DestroyJavaVM" which is not my program. I'm using VisualVM because it is the only free Java profiler I could find. Any suggestions? Here are my VisualVM settings:

enter image description here

like image 398
Nathan Bierema Avatar asked Feb 04 '17 19:02

Nathan Bierema


People also ask

How do I run VisualVM?

You can access VisualVM from the bin directory of the JDK: On a Windows system, start VisualVM by double-clicking jvisualvm.exe. You can also select VisualVM from the Start menu (if Windchill shortcuts are installed). On other systems, start VisualVM by invoking the jvisualvm script.

Is VisualVM included in JDK?

Various optional tools, including Java VisualVM, are provided with the Java Development Kit (JDK) for retrieving different types of data about running JVM software instances.

Does VisualVM work with Java 11?

Use VisualVM bundled with GraalVMGraalVM contains a fully compliant Java SE 8, Java SE 11, and Java SE 17 JDK distribution based on Oracle JDK and OpenJDK. It features an innovative JIT compiler which may noticeably improve performance of Java applications, compared to the standard Oracle JDK or OpenJDK.

How do I use memory profile in IntelliJ?

From the main menu, select View | Tool Windows | Profiler. Right-click the necessary process in the Profiler tool window and select CPU and Memory Live Charts. A new tab opens in which you can see the amount of resources the selected process consumes.


1 Answers

As others have suggested, take a look at your "Start profiling from class" setting.

But you might want to consider it being a timing issue. As you can see in the background, the process you want to debug is already finished.

Check in the call tree and in the list of processes to the left what you are debugging. In your screenshot you are debugging the destruction of the JVM. That does not include your code, so you should not see it there.

like image 100
mbruns42 Avatar answered Oct 17 '22 01:10

mbruns42