Difference between sampling and profiling in jVisualVM

JavaJvmHeap MemoryJvisualvm

Java Problem Overview


VisualVM has two separate tabs for sampling and profiling. What is the difference between sampling and profiling in VisualVM?

Java Solutions


Solution 1 - Java

Sampling means taking lots of thread dumps and analyzing stack traces. This is usually faster, does not require runtime changes in your bytecode (which may break it), but is also less accurate.

Profiling means instrumenting your classes and methods, so they "report" whenever they are run. This is more accurate, as it counts every invocation of instrumented method, not only those caught when the dump is done. However instrumentation means that the bytecode of your classes is changed, and this may break your program. Actually, for that reason, using profiling on large application servers (like JBoss, or WebLogic) often causes everything to die or hang.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionParagView Question on Stackoverflow
Solution 1 - JavanpeView Answer on Stackoverflow