Emilian has posted 6 posts at DZone. View Full User Profile

Using VisualVM, BTrace & Good Old Web Search

08.20.2009
| 26584 views |
  • submit to reddit
Getting this started is quite easy on the VisualVM side, but it takes forever to actually start gathering data. The reason is the bytecode instrumentation that is done for a lot of the NetBeans IDE classes by the Profiler. This means that if VisualVM complains that the application isn't responding and suggests to stop profiling, you'll need to answer "No" and let it do its thing:

VisualVM Profiler tab

Well, with a little patience I could see data coming in. Pretty soon I noticed at the top of the list two classes that shouldn't have been there:

org.netbeans.core.TimableEventQueue.postEvent with 31.3%
apple.laf.CUIAquaProgressBar$Animator.actionPerformed with 25.1%
org.netbeans.core.TimableEventQueue.dispatchEvent with 5%

So, it looked like the EventQueue (well, the one used by NetBeans IDE anyhow) was being really busy this whole time calling an OSX-specific ProgressBar animator class. The only thing was -- there was no progress bar on the screen! Actually, the whole NetBeans IDE was hidden away... so Swing should have been really quiet.

Well, it started looking as if we had some sort of "leak" here, i.e., some object that clearly isn't being disposed properly. I instantly thought that the culprit might be some class inside the NetBeans Progress API/UI, since this is the module that shows that little progress component in the lower-right corner of the main window. This was just a hunch, though, since I know a bit about the internals of NetBeans IDE, but I had no way to prove it yet or, more importantly, to fix it.

I returned to VisualVM knowing what classes to look for and I requested a heap dump. This is a snapshot of the applications' memory at that point. I went into the Classes tab and I searched for our CUIAquaProgressBar$Animator class:

VisualVM Heap dump

 

Now my reasoning was to find some JProgressBar reference and, sure enough, using the Fields area in the Instances tab I found a link to the progress bar:

VisualVM Heapdump reference

 

OK, so indeed we have some wild JProgressBars being called, more to the point NbProgressBars. We are actually getting somewhere now!

Published at DZone with permission of its author, Emilian Bold.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Philippe Lhoste replied on Fri, 2009/08/21 - 4:25am

Beyond the particular context not interesting everyone (I don't use OSX nor NetBeans...), I appreciated the report of the detective work you did, showing good usage of tools. I knew VisualVM but it is the first time I see how to use BTrace, which is indeed an interesting tool if you can't (or don't want to) alter source code to add println's...

Thanks for sharing!

Mateo Gomez replied on Tue, 2012/04/17 - 12:20am

thanks for sharing this valuable information to us, i know you have put in a lot of hard work in this project

 

 mexican dessert recipes

Matt Coleman replied on Tue, 2012/04/17 - 12:46am

debugging is such an important thing to do to fix the program and make it work

 

graphic design buffalo

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.