VisualVM unable to sampler memory

2020-05-23 02:32发布

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?

10条回答
SAY GOODBYE
2楼-- · 2020-05-23 03:20

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
查看更多
姐就是有狂的资本
3楼-- · 2020-05-23 03:24

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/

查看更多
乱世女痞
4楼-- · 2020-05-23 03:30

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.

查看更多
▲ chillily
5楼-- · 2020-05-23 03:34

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.

查看更多
登录 后发表回答