Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why won't the VisualVM Profiler profile my Scala console application?

I assume the question is strongly related to this one but it is closed and the solution does not seem clear to me.

I am trying to use VisualVM to profile a console Scala application of mine. I do this by starting VisualVM, starting my Scala application, opening its node in VisualVM, going to the "Profiler" tab and clicking "CPU". The button goes grey for some time (while status never changes to anything from "profiling inactive"), then back active but no profiling data appears shown.

The application does some file reading, data processing (which takes about a minute), stdout data output and exits. I've also tried adding Thread.sleep(60000) to the beginning and to the end of the program to ensure enough time for VisualVM to capture it and do the job, nothing changed though.

Unlike to the related question I've linked to I don't launch my app from Eclipse or anything else - I use the following command line to launch it:

java -classpath myapp.jar:lib/* MyApp.Main

all the libraries (including scala-library.jar) are put in lib/. The app works as expected.

Updates:

  • I have tried YourKit Java Profiler 11.0.2 and it fails with AttachNotSupportedException.
  • I've managed with YourKit by attaching the agent manually.
  • It seems worth stressing that I neither run the application from an IDE (or a build tool) nor have I modified any JVM options but classpath. As far as I understand this problem appears to depend on a JVM version and user/permission issues and. The objective is to figure out the actual mechanism of the problem and the way to configure all the things to work.

Versions of the software used:

  • YourKit Java Profiler 11.0.2
  • VisualVM 1.3.4
  • SBT 0.12.3 (to build but not to run (I've tried both actually))
  • Scala 2.9.2
  • Oracle Java 1.7.0_04-b20
  • XUbuntu Linux 12.04 32-bit i386
  • Linux kernel 3.2.0-24-generic-pae
like image 989
Ivan Avatar asked May 14 '12 21:05

Ivan


1 Answers

I have used VisualVM to profile a Scala application two days ago, so I believe it should work. Here are my suggestions:

  • Take out YourKit out of the equation and run things without it for a starter
  • Take out scala out of the equation, try profiling a Java hello world that does while (true) { Thread.sleep(10000); }
  • Get that to work then put back Scala, then put back YourKit.

Edit: based on your input, I suggest to explicitly set the remote JMX connection. You can start java with the following options:

-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=20000
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

Then in VisualVM, add a JMX connection to localhost:20000.

like image 131
huynhjl Avatar answered Oct 26 '22 22:10

huynhjl