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

Using VisualVM, BTrace & Good Old Web Search

  • submit to reddit
The story starts with my pattern of being off the grid half of each day. This really lets me appreciate a good battery and, while my Mac battery is pretty decent, I can literally feel it drain while doing hard Java work with NetBeans IDE, Maven, and big recompiles.

Now, while battery depletion under heavy load is perfectly normal, it does force you to keep a keen eye on CPU usage in the OSX Activity Monitor. That's how I noticed that while idle, NetBeans IDE was taking about 16% of my CPU... doing nothing really.

The first thing I wanted to know was what was going on in there? So I took VisualVM, connected it to the NetBeans IDE instance, and forced a Thread Dump:

VisualVM Threads tab and Thread dump button

This basically is a list of stack traces for all the threads, so that you can see the application's current state of execution. In my case, I probably didn't press the button at the right time, since I caught the threads all in a WAITING state, meaning that not much CPU should have been used: 

VisualVM Thread dump list

Well, since the thread dump is just a quick snapshot, it was clear that I wasn't going to get a good view of what was consuming CPU, so I went to the heavy weight option: CPU Profiling.

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.)


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

Ray Naa replied on Wed, 2014/09/24 - 4:00pm


We needed help with our SQL issues...http://nosqlguide.com was really helpful, a great resource and really helped us find a solution fast too.
NoSQL vs Relational databases

Ray Naa replied on Tue, 2014/09/30 - 3:10pm


While researching housing tools, I hit upon this real estate website,<a href="http://ochousingnews.com/">OC Housing Market News</a>.The news reporting and analysis on this site is of very high quality, the cartoons are hilarious, and the many user guides are extremely valuable. I recommend using this website to experience it.
Housing News

Comment viewing options

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