Java – performance analysis using IntelliJ and debug in visualvm

I want to describe the test application launched by IntelliJ For analysis, I used visual VM

I use the parameter - j-dorg netbeans. profiler. Separateconsole = true starts the Java tool

I started the application with the VM parameter - xverify: none, otherwise visualvm would throw an error when I started analysis (redefinition failed, error 62)

I want to analyze my application before executing any important code, so I try to set a breakpoint and start analysis in visual VM The problem is that when I wait at the breakpoint, visual VM does not respond to any interaction Did I miss anything?

During normal execution (without debugging), my program waits for input, so I can analyze it without debugging But what if a program doesn't have such a "waiting point"?

My test application looks like:

package my.visualvm.example;

import java.util.Scanner;

public class MainClass {

    public static void main(String[] args) {

        System.out.println("Starting Application: " + MainClass.class.getSimpleName());

        Scanner scanner = new Scanner(system.in);

        while (scanner.hasNext()) {
            double value = scanner.nextDouble();
            if (value == 0d) {
                break;
            }
            System.out.println(Powa.powaPowa(value));
        }

        System.out.println("Stopping Application: " + MainClass.class.getSimpleName());
    }

}

Other courses:

package my.visualvm.example;

final class Powa {

    private Powa() {
    }

    static double powaPowa(double powa) {
        return Math.pow(powa,2);
    }
}

Solution

Set the breakpoint to suspend only the current thread

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>