質問

When profiling the CPU time of an application with VisualVM, one can see a "Call Tree" tab after taking a snapshot. But in my case, the call tree only shows some RMI TCP classes and methods, but no single class of my application.

How can I display the correct call tree?

enter image description here

役に立ちましたか?

解決

Possibilities

  1. The Profiler settings are excluding your classes. Change the excludes in the Profiler settings.
  2. Your application was idle while the profiler was running. Attach the profiler then cause the program to execute the code you want to profile.
  3. You might be profiling the wrong JVM. RMI makes it pretty easy to call into another JVM. Maybe you need to be profiling the other side of that RMI connection.

There is a "Settings" checkbox on the Profiler tab. If you check the Settings box another panel will show up that lets you configure what classes the profiler collects data about.

Here is a screenshot. screeshot of jvisualvm with Profiler "Settings" box checked.

他のヒント

As @Holger said, the profiler's/sampler's snapshots are supposed to only show running threads. However, I found by personal experience that sampling snapshots sometimes show more threads that profiling ones.

Moreover, VisualVM's sampler enables you to see each thread's CPU Time in real-time (without taking a snapshot), no matter if it's running, sleeping, waiting or monitoring.

I do not understand why this happens, since profiling should be more accurate than sampling (see here the difference), but it does.

All in all, I'd recommend that you try the sampler, and see if it works.

The call tree only shows threads which really ran during the sampling/profiling (were not sleeping all the time) and whose stack traces got not filtered out entirely. The filter is set up before starting a sampling or profiling. When enabling the “settings” checkbox in the upper right corner you can set up the filter. In case of the sampler you can also set up the sampling frequency which is a trade-off between performance and the risk to oversee a running state of a thread. But it could be that your application was really idle during the profiling. Then the only threads you see are the RMI threads maintaining the connection to VisualVM.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top