1

I'm confused a little: AFAIK VisualVM perform profiling and sampling, so does it mean it not only makes dumps (thread stacks + memory state) but also instrumenting the code?

From here: https://stackoverflow.com/a/12130149/10894456 explained the profiling implies instrumenting. But does VisualVM makes instrumenting by itself or need something to prepare (like Java Agent or something)?

J.J. Beam
  • 2,612
  • 2
  • 26
  • 55

1 Answers1

4

Yes, when you use the Profiler, VisualVM will instrument the bytecode as necessary. This can only be done via an Agent, so VisualVM includes such a Java Agent. When you are connected to a JVM on the same machine, it may use the Attach API to load the Agent into the target JVM dynamically. So in this use case, it doesn’t need additional preparation steps on the user’s side.

Holger
  • 285,553
  • 42
  • 434
  • 765
  • clear, so how VisualVM does know which part of my program I wanna check? Or does it instrumenting every object, every method ? – J.J. Beam Apr 06 '20 at 16:13
  • 2
    It’s not instrumenting objects, but methods (of classes). There’s a “Settings” checkbox in the top right corner. When it is toggled, filter settings are visible. All classes matching the inclusion filter or not matching the exclusion filter will get instrumented. This can indeed be a lot of stuff. That’s why the sampler can be much faster to get the first results but also have less overall overhead. I use the sampler, most of the time. – Holger Apr 06 '20 at 16:17