visualvm cannot see a java process launched from cygwin
Asked Answered
S

4

19

If I start a java process in a cygwin console, and then launch visualVm, the later cannot see the former.

If I start the same process in a Dos console visualvm sees it fine. I am in jdk1.6.0_25. This happens both in win7 32b, and in win7 64b with a 64b jvm.

Anyone can think of an explanation/workaround?

Stoker answered 13/7, 2011 at 9:58 Comment(6)
are both from the same system user?Levenson
Any parameter? What happens if you start the visualVM from cygwin? (What happens if you explicitly reference it via jmx-connection? Right mouse click "Add JMX connection")Levenson
@FlorianOver: Good point. I have the same problem, but if I start JVisualVM from inside Cygwin, I can see the Java proc launched from Cygwin. However, I don't see Java procs launched outside Cygwin. Strange...Depolymerize
That's caused by the fact that Java uses a directory (hsperfdata_USERNAME) to save information consumed then by visualvm. Usually it's in %userprofile%/AppData/Local/Temp. For some reason, under cygwin, Java and visualvm looks for that dir in /tmp. Cannot figure out how it Java knows about /tmp.Misadvise
Oh wow! For many years I was thinking it was Gradle that was somehow making launched java processes private from debugging. (Versus running from an IDE.) I would never have guessed it was cygwin / temp directory issues.Sunless
@BartoszKlimek looks like all Java processes (debugger and debuggee) just go via the $TMP environment variable -- this is the key difference in the cygwin environmentSunless
M
4

I had the same problem. The vm was not shown automatically but I was able to connect via "Add JMX Connection", using hostname and jmx.remote.port...

On VisualVM go to File -> Add JMX Connection

localhost:3333

Add vm parameter at startup e.g.:

 -Dcom.sun.management.jmxremote.port=3333
 -Dcom.sun.management.jmxremote.ssl=false
 -Dcom.sun.management.jmxremote.authenticate=false
Menstrual answered 13/7, 2011 at 13:13 Comment(0)
E
13

I fixed the problem by running VisualVM from within Cygwin. If you prefer not to profile using a remote JMX connection, you can run both VisualVM and your Java program using Cygwin:

Open the Cygwin Console window, navigate to visual_vm.exe and run that file from within the Cygwin environment.

Edouard answered 7/2, 2012 at 13:1 Comment(1)
Or simply $JAVA_HOME/bin/jvisualvmBonar
M
4

I had the same problem. The vm was not shown automatically but I was able to connect via "Add JMX Connection", using hostname and jmx.remote.port...

On VisualVM go to File -> Add JMX Connection

localhost:3333

Add vm parameter at startup e.g.:

 -Dcom.sun.management.jmxremote.port=3333
 -Dcom.sun.management.jmxremote.ssl=false
 -Dcom.sun.management.jmxremote.authenticate=false
Menstrual answered 13/7, 2011 at 13:13 Comment(0)
A
2

VisualVM can automatically detect local applications running under the same user. So one explanation can be that cygwin process is running under the different user. Make sure that both VisualVM and monitored application is running under JDK 6 update 25. JDK 6 update 25 has a fix for the following JDK bug #6938627, which can affect your case.

Alkalinity answered 14/7, 2011 at 13:56 Comment(0)
S
0

The opposite approach to @seanhodges answer is to launch the application to debug with a modified environment, pointing it back to your Windows User Temp directory

For example if you normally do:

    ./gradlew run

And say your TEMP directory on Windows (according to your User environment variables) is:

    T:\Temp

You can do one of these instead:

    TMP=T:\\Temp ./gradlew run

    TMP=/cygdrive/t/Temp ./gradlew run

(they both seem to work)

Sunless answered 24/10, 2019 at 12:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.