Luke Luke - 1 year ago 341
Java Question

Why won't the VisualVM Profiler profile my application?

I've created a simple 1 file java application that iterates through a loop, calls some functions, allocates some memory, adds some numbers, etc. I run that application via eclipse's

Run As->Java Application

The running application shows up in Java VisualVM under

I double click on that application and go to the Profiler tab.

The default settings are:

Start profiling from classes: my.main.package.**

Do not profile classes: java.*, javax.*,
sun.*, sunw.*, com.sun.*

I click on
. The
buttons gray out. Nothing happens.

profiling inactive

When my application terminates the
application terminated

What am I doing wrong here? Are there some settings I need to tweak? Do I need to set a VM flag when I launch my application?

Answer Source

I'd guess the issue relates to the application being started from within Eclipse, this is because JVisualVM expects to find data in the directory (usually C:\Users\[your username]\AppData\Local\Temp\hsperfdata_[your username] on a Windows system).

I assume rather than in the normal location where JPS, JVisualVM etc. expects it, Eclipse puts the data in it's own temp folder?

If so, try invoking JVisualVM using jvisualvm[Eclipse's temp directory] to explicitly tell it where that data is.

If you can't find the hsperfdata_$USER folder, try just running your application outside Eclipse in the usual command line Java way.

Also note that there was a bug affecting the temp folder (case sensitivity) introduced around 1.6.0_23, so maybe you'd benefit by updating to a more recent Java 6 (or 7) build?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download