Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attaching Source to VisualVM? [duplicate]

Tags:

java

visualvm

I'm running VisualVM to profile a simple Java application. When I double-click on a method in the profiling pane (hoping to get more details on it), then it says "No source found for class ....". I know where the source is. How do I tell VisualVM where to look?

like image 901
Nathaniel J. Smith Avatar asked Jul 07 '14 19:07

Nathaniel J. Smith


People also ask

How do I connect to a VisualVM remote server?

Connecting to a Remote Host To add a remote host, right-click the Remote node in the Applications window, choose Add Remote Host and type the host name or IP address in the Add Remote Host dialog box. (You can also specify a display name that will be used to refer to the host when listed under the Remote node.)

What is difference between JConsole and VisualVM?

JConsole uses only JMX, but VisualVM uses other monitoring technologies like Jvmstat, Attach API and SA in addition to JMX. It can merge data from all those monitoring technologies in one place and the user does not need to think which technology he should use in particular situation.

What is retained in VisualVM?

I think the best definition for "Retained" in the VisualVM is the amount of memory that will remain after garbage collection. In some cases it can be bigger than the "Size" since it reference other objects (or collections) directly or indirectly.


1 Answers

I took a stack dump of the VisualVM process while it was displaying that error dialog, and it seems that the problem lies in the class org.netbeans.modules.profiler.api.GoToSource, in the method openSourceImpl.

This method tries to load the source using any registered implementations of the GoToSourceProvider service provider interface, and displays the error message if none of them manage to display the source code in question.

My guess is that the current, default version of VisualVM doesn't have any GoToSourceProviders registered, and therefore will always fail to look-up source code.

From the package name it appears that GoToSourceProvider is an SPI for the profiler module, but I wasn't able to find any documentation on how to implement this SPI, and it doesn't seem to be part of the VisualVM extension points.

like image 170
alphaloop Avatar answered Sep 19 '22 16:09

alphaloop