2

When I attach JVisualVM to remote JVM through JMX, I see the "Sampler" tab instead of the "Profiler" tab. I know there is a difference between Sampling and Profiling. I'm more interested in Profiling (specifically CPU Profiling).

Is "Profiler" available in JVisualVM for remote JVM at first place? If so, please mention the specific JVM startup flags. If it's not available, what are the alternatives? Please understand that I can't login to remote hosts.

valiano
  • 16,433
  • 7
  • 64
  • 79
RRM
  • 2,495
  • 29
  • 46

1 Answers1

2

VisualVM does not support remote profiling as you can find in its source code:

    boolean supportsProfiling(Application application) {
        // Application already being profiled (Startup Profiler)
        if (application == getProfiledApplication()) return true;

        // Remote profiling is not supported
        if (application.getHost() != Host.LOCALHOST) return false;

        ...

In fact, sampling is a good alternative to an intrumenting profiler if you wish to find CPU-consuming bottlenecks.

Which tool is better depends on your requirement, but the tool discussion is out of the scope of this question, and is off-topic on Stack Overflow.

apangin
  • 92,924
  • 10
  • 193
  • 247
  • Thanks for the precise code reference. [here](https://stackoverflow.com/questions/12130107/difference-between-sampling-and-profiling-in-jvisualvm?rq=1) is why I wanted Profiling rather than Sampling. – RRM Jul 10 '17 at 09:42
  • @RRMadhav In practice sampling is usually even *more accurate* than instrumenting profiler, since it does not modify the code you run and has very small run-time overhead. However, *some* sampling profilers including VisualVM may suffer from [safepoint bias](http://psy-lob-saw.blogspot.ru/2016/02/why-most-sampling-java-profilers-are.html) problem. – apangin Jul 10 '17 at 11:44