Can anyone explain the science behind the sampling functionality of visualvm ?
I would have thought that collecting the amount of CPU spent on each particular method would require instrumenting the application to be profiled, but it doesnt look like visualvm is doing any kind of instrumenting, so I'm curious to know how it's done...
It has a timer. When the timer fires, it copies the current contents of every thread's stack. Then it translates the stack frames into method and object names, and records a count against the relative methods.
Because of this, it doesn't need to instrument the code, and is therefore very lightweight. However, because it doesn't instrument the code is can miss short-running stuff. So it's mostly useful either for tracking long-running performance problems, or to quickly identify a serious hot-spot in your code.
It looks like the new VisualVM-Sampler plugin gather performance and memory data by periodically polling the monitored application for thread dumps or memory histograms. Check this article for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With