I want to filter what classes are being cpu-profiled in Java VisualVm (Version 1.7.0 b110325). For this, I tried under Profiler -> Settings -> CPU-Settings to set "Profile only classes" to my package under test, which had no effect. Then I tried to get rid of all java.* and sun.* classes by setting them in "Do not profile classes", which had no effect either.
Is this simply a bug? Or am I missing something? Is there a workaround? I mean other than:
- paying for a better profiler
- doing sampling by hand (see One could use a profiler, but why not just halt the program?)
- switch to the Call Tree view, which is no good since only the Profiler view gives me the percentages of consumed CPU per method.
I want to do this mainly to get halfway correct percentages of consumed CPU per method. For this, I need to get rid of the annoying measurements, e.g. for sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run()
(around 70%). Many users seem to have this problem, see e.g.
Best Answer
The reason you see
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run()
in the profile is that you left the option Profile new Runnables selected.Also, if you took a snapshot of your profiling session you would be able to see the whole callstack for any hotspot method - this way you could navigate from the
run()
method down to your own application logic methods, filtering out the noise generated by the Profile new Runnables option.