简体   繁体   中英

VisualVM unable to sampler memory

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?

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.

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.

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.

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)

Here is my solution for similar problem: https://stackoverflow.com/a/16330238/715483

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/

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.

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.

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.

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.

在此输入图像描述

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM