VisualVM unable to sampler memory
Asked Answered
P

10

28

I have a tomcat instance with the JMXRemote parameter configured. The local VisualVM is able to get a sampler on CPU, however, not for Memory. The memory button is grayed out with a summary saying: "Memory sampling: Not available. Cannot connect to target application. Make sure the application is running on a supported JDK 6 or JDK 7"

JMXRemote parameter:

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9086
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

Tomcat JDK version:

JDK1.6.0.30

VisualVM version:

Version: 1.6.0_30 (Build 1320-110325); platform 110131-9c8b3bfb3a1e
System: Windows Server 2008 R2 (6.1) , amd64 64bit
Java: 1.6.0_30; Java HotSpot(TM) 64-Bit Server VM (20.5-b03, mixed mode)
Vendor: Sun Microsystems Inc., http://java.sun.com/
Environment: Cp1252; en_US (visualvm)
Userdir: C:\Users\Administrator\AppData\Roaming\.visualvm\7
Clusters: C:\Program Files\Java\jdk1.6.0_30\lib\visualvm\platform
C:\Program Files\Java\jdk1.6.0_30\lib\visualvm\visualvm
C:\Program Files\Java\jdk1.6.0_30\lib\visualvm\profiler

Tomcat version:

Tomcat 6.0.32

I am running both the VisualVM and Tomcat at win server 2008. Anything i did wrong?

Presbyterian answered 10/1, 2012 at 7:32 Comment(4)
crab... you're right, i post the wrong information. let me test it again with the same JDKPresbyterian
VisualVM is very version specific. I assume its still under fairly rapid development.Gosnell
see also #727143Mayday
For me staring visualvm as sudo user solve the issue...Repro
T
9

I had the same problem before. You must have downloaded the version from jvisualvm homepage, right? Don't do it! If you use new jdk 1.7, VisualVM is already packaged in your jdk folder. Use this version, you will not have any problem with memory sample.

Trona answered 23/4, 2013 at 9:36 Comment(1)
That did the trick for me. If using jdk 1.7 visualvm is already part of the jdk in bin/. This made memory sampling work.Assumpsit
F
5

This blog post leads me to believe that the temp directories of JVisualVM and Tomcat need to be the same for memory sampling to work. One of the comments on the post:

the temp directory must be set to the one used by JVisualVM, which can be discovered from the VisualVM system properties tab (java.io.tmpdir). Once I set the CATALINA_TMPDIR directory properly, this worked beautifully.

Feign answered 23/8, 2012 at 16:50 Comment(2)
I believe only CPU sampling can be done remotely. For memory sampling you might try running visualvm on the remote machine and using X11 forwarding to view it, if that's a possibility.Feign
I tried aligning the temp directories for the Tomcat Windows service and visualvm to both be C:\Windows\Temp but I'm still getting the message "Not supported for this JVM" in the visualvm views.Beker
P
3

I've just run into this same issue and the answers above solved my problem but it took me a while to figure out how. Just in case anyone else is still having trouble and ends up this far down the thread, I was using the JDK that is part of the weblogic server configured through Eclipse and not the JDK that I installed seperately. I'm still a junior programmer and I wasn't putting 2 and 2 together until I started looking through my eclipse settings and verified my Installed JREs.

Ran the jvisualvm.exe from the weblogic jdk and all worked.

Psychotherapy answered 19/4, 2018 at 14:47 Comment(1)
You can also specify which JDK to use with a command like this: visualvm --jdkhome "C:\Program Files\Java\jdk-11.0.2"Landin
G
1

I would check the version of VisualVM is exactly the same as the JVM.

VisualVM is very version specific. I assume its still under fairly rapid development.

(Re posted as an answer as it may be the solution)

Gosnell answered 10/1, 2012 at 8:4 Comment(0)
R
0

I've faced similar issues with JVisualVM, I've even asked a question about it here

A couple of insights/advices:

  1. So, in order to sample memory you don't need jmx options.
  2. I would double check whether you have 64 bit jvms installed along with 32 bit jdks on the same machine (even if they're not running and all the environment vars defined properly), I've read somewhere that sometimes it drives the JVisualVM crazy :) (yes I know it doesn't sound reasonable to us, java developers)

  3. If it doesn't work, just uninstall all jdks that you have and install only 1 that you need. It can solve the issue.

I hope it will help you to resolve the issue, after all like Peter said these things are new and evolving

Ronel answered 10/1, 2012 at 8:25 Comment(1)
1) if i remove jmx, local shows only 1 item "VisualVM" under the VisualVM application panel 2) there was only 1 JDK 1.6.0_26 and i think the server came together with a JRE6 to began with. i have install the JDK 1.6.0_30 today to see if the new JDK helps. 3) i'll will try that and see what happenPresbyterian
B
0

Here is my solution for similar problem: https://mcmap.net/q/504746/-jvisualvm-memory-sampling-remote-applications-are-not-supported

You can resolved this error by

$ ssh -Y user@remotemachine

$ wget http://java.net/projects/visualvm/downloads/download/release135/visualvm_135.zip

$ unzip visualvm_135.zip

$ cd visualvm_135/bin

$ ./visualvm

This instance of visualvm will be full featured, including memory and CPU sampling.

Read more about it here: http://shahriarinia.blogspot.com/2013/05/java-cpumemory-heap-usage-monitoring.html

http://mshahriarinia.com/

Blackpoll answered 2/5, 2013 at 4:35 Comment(0)
L
0

Make sure your VirtualVM/JDK is a 32-bit copy if your JRE is. If you are using Eclipse, check the selected JRE on Installed JRE's section.

Lipography answered 3/7, 2013 at 23:37 Comment(0)
S
0

And I have the same problem.

I always launched tomcat as a service and connected it with visualvm through jmx connection.

When had corrected catalina.bat:

    set JAVA_OPTS=%JAVA_OPTS% 
    -Dcom.sun.management.jmxremote=true 
    -Dcom.sun.management.jmxremote.port=9090 
    -Dcom.sun.management.jmxremote.ssl=false 
    -Dcom.sun.management.jmxremote.authenticate=false

and launched it with startup.bat, visualvm automatically determine tomcat, and memory sampling was active.

Somatoplasm answered 7/2, 2014 at 12:59 Comment(0)
H
0

I've got the same problem but with different envirnoment. My server was a Linux machine, the client a Windows 7 machine, but the problem is the same.

The solution was to launch the jvisualvm in the same machine and with the same user that is running the targeted application. If i run jvisualvm with other other user (ex: root) the memory button became gray.

Halstead answered 21/3, 2014 at 7:52 Comment(0)
F
0

Firstly, JMX should be enabled. Add the linked command line environment variables necessary to activate JMX if you haven't.

The environment variable CATALINA_TMPDIR should be set to match the JVisualVM as seen in the "System properties" tab of the Local > VisualVM. You can open this by double clicking on the "VisualVM" labeled entry in the Applications pane on the left.

Environment variables can be set by searching for environment, "edit environment variables for your account". New... > Enter a name and value.

enter image description here

If you would like the temporary directory of VisualVM to be somewhere else, you'll have to launch VisualVM from the command line and add an argument.

C:\Program Files\Java\jdk1.8.0_65\bin>jvisualvm.exe -J-Djava.io.tmpdir=C:\Users\You\Temp
Fairground answered 4/10, 2018 at 21:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.