VisualVM 无法采样内存
我有一个配置了 JMXRemote 参数的 tomcat 实例。本地 VisualVM 能够在 CPU 上获取采样器,但不能在内存上获取采样器。内存按钮呈灰色显示,并显示一条摘要:“内存采样:不可用。无法连接到目标应用程序。请确保应用程序在受支持的 JDK 6 或 JDK 7 上运行”
JMXRemote 参数:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9086
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
Tomcat JDK 版本:
JDK1.6.0.30
VisualVM 版本:
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版本:
Tomcat 6.0.32
我在 win server 2008 上运行 VisualVM 和 Tomcat。我做错了什么吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
我以前也遇到过同样的问题。
你一定是从jvisualvm主页下载的版本吧?
不要这样做!
如果您使用新的jdk 1.7,VisualVM已经打包在您的jdk文件夹中。
使用这个版本,内存样本不会有任何问题。
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.
这篇博文 让我相信 JVisualVM 和 Tomcat 的临时目录必须相同才能内存采样工作。该帖子的评论之一:
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:
我刚刚遇到了同样的问题,上面的答案解决了我的问题,但我花了一段时间才弄清楚如何解决。以防万一其他人仍然遇到麻烦并最终陷入困境,我使用的是 JDK,它是通过 Eclipse 配置的 weblogic 服务器的一部分,而不是我单独安装的 JDK。我仍然是一名初级程序员,直到我开始查看 Eclipse 设置并验证我安装的 JRE 之前,我才将 2 和 2 放在一起。
从 weblogic jdk 运行 jvisualvm.exe 并且一切正常。
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.
我会检查 VisualVM 的版本是否与 JVM 完全相同。
VisualVM 是非常特定于版本的。我认为它仍处于相当快速的发展之中。
(重新发布为答案,因为它可能是解决方案)
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)
我在使用 JVisualVM 时遇到了类似的问题,我什至问了一个关于它的问题 这里
一些见解/建议:
我会仔细检查您是否在同一台计算机上安装了 64 位 jvm 和 32 位 jdks(即使它们没有运行并且所有环境变量都已正确定义),我在某处读到有时它会驱动JVisualVM 疯狂:)(是的,我知道这对我们 Java 开发人员来说听起来不合理)
如果它不起作用,只需卸载您拥有的所有 jdks 并仅安装您需要的 1 个。它可以解决问题。
我希望它能帮助您解决问题,毕竟就像彼得所说,这些事情是新的并且不断发展
I've faced similar issues with JVisualVM, I've even asked a question about it here
A couple of insights/advices:
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)
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
这是我对类似问题的解决方案: https://stackoverflow.com/a/16330238/715483
您可以解决此错误通过
$ 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
该 VisualVM 实例将具有完整功能,包括内存和CPU采样。
在这里阅读更多相关信息:http://shahriarinia。 blogspot.com/2013/05/java-cpumemory-heap-usage-monitoring.html
http://mshahriarinia.com/
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/
如果您的 JRE 是,请确保您的 VirtualVM/JDK 是 32 位副本。如果您使用的是 Eclipse,请在“已安装的 JRE”部分中检查所选的 JRE。
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.
我也有同样的问题。
我总是将 tomcat 作为服务启动,并通过 jmx 连接将其与 VisualVM 连接。
当更正catalina.bat:
并使用startup.bat启动它时,VisualVM自动确定tomcat,并且内存采样处于活动状态。
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:
and launched it with startup.bat, visualvm automatically determine tomcat, and memory sampling was active.
我有同样的问题,但环境不同。我的服务器是Linux机器,客户端是Windows 7机器,但问题是一样的。
解决方案是在同一台计算机上并使用运行目标应用程序的同一用户启动 jvisualvm。如果我与其他用户(例如:root)一起运行 jvisualvm,内存按钮会变成灰色。
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.
首先,应启用 JMX。添加激活 JMX 所需的链接命令行环境变量(如果尚未添加)。
应将环境变量 CATALINA_TMPDIR 设置为与 JVisualVM 匹配,如“本地”>“系统属性”选项卡中所示。视觉虚拟机。您可以通过双击左侧“应用程序”窗格中标记为“VisualVM”的条目来打开它。
可以通过搜索环境“编辑您帐户的环境变量”来设置环境变量。新...>>输入名称和值。
如果您希望 VisualVM 的临时目录位于其他位置,则必须从命令行启动 VisualVM 并添加参数。
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.