Forums > Java

VisualVM Profiling

February 14, 2012 | 4:36 pm

Has anyone successfully used VisualVM for profiling Java code running in an MXJ? I’ve been able to use the Sampler without issue, but when I use the Profiler, I see a bunch of information gathered but it doesn’t seem to report on my own classes being used in MXJ.

I’ve looked at the VisualVM manual a little bit, but not enough to disqualify me from "RTFM"—but if anyone has done this any tips would be appreciated (or if you also tried and failed, that would be nice to know too).

Thanks!



Jan
February 15, 2012 | 12:35 pm

Hey Roth,

I haven´t worked with VisualVM+Max yet (Though it seems i´ll try to get run as soon as I find a free evening …).

A quick look at the docs I saw that only some feature are supported for remote debugging (which i believe you have to do if the code is running inside max). Maybe there is something there…

But to be honest it is pure guessing!

Jan


February 15, 2012 | 2:24 pm

A quick look at the docs I saw that only some feature are supported for remote debugging (which i believe you have to do if the code is running inside max).

I did see that stuff, but from my experiments so far it doesn’t seem necessary. When I start a profiling session, the following prints in the Max Window:

Profiler Agent: Waiting for connection on port 5140 (Protocol version: 10)
Profiler Agent: Established connection with the tool
Profiler Agent: Local accelerated session

So it appears the necessary connections are being made but all the classes being profiled have nothing to do with anything in my mxj. I think there is something that needs to be done to make sure you are profiling the right classes, but I haven’t figured out how to manage that—and was hoping someone out here on the internet had some sage wisdom for me in the meantime until I have a chance to study the documentation more (lazy, I know).



Jan
February 26, 2012 | 9:02 pm

Hi Roth,

did you got VisualVM to work? I’d like to give it a shot the next days.. ;)

Jan


February 27, 2012 | 10:23 am

Yes, was waiting until I did it a few more times to make sure I knew what I was doing before posting. You don’t need to set up a remote profiling connect. Max will show up in the list of Local applications (although for me, it shows up as " (pid ####)". It may not be the only thing if you are running another Java app (like Ecpipse) at the same time, so if you need to, check (if you’re on a Mac) Activity Monitor or at the terminal enter ps -ax | grep Max for the process ID of Max.

I discovered a few things things:

  1. You need to exclude java.net.*, or at least whatever java.net.TCPSOMETHINGSOMETHING that you will likely see as the thing taking up the most CPU time (I think this is the class handling the socket that profiling communication happens with Max over—I think I read that this type of method doesn’t actually return for a while after it starts a asynchronous processes to communicate).
  2. You should list the package the MXJ you want to profile is in under "Start profiling from classes" (you can list the class specifically that you want to start profiling from, a whole package using the * wildcard, or include subpackages with **).
  3. If you do those first two things and get no profiling results, you may need to mess around with some magic of the order of starting VisualVM, Max, and starting the JVM in Max

Also, try profiling first, it is not as accurate, but if your code base is big, it can help you target where you need to profile.



Jan
February 28, 2012 | 2:49 am

Thanks!!! That will speed up things!


Viewing 6 posts - 1 through 6 (of 6 total)