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).
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!
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).
did you got VisualVM to work? I’d like to give it a shot the next days.. ;)
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 "
ps -ax | grep Max for the process ID of Max.
I discovered a few things things:
- 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).
- 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 **).
- 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.
Thanks!!! That will speed up things!
Forums > Java