visualvm intellij “Failed to create JMX connection to target application” profiling not working

时光毁灭记忆、已成空白 提交于 2019-11-30 11:35:49

Maybe this helps:

java -Dcom.sun.management.jmxremote \
  -Dcom.sun.management.jmxremote.port=9010 \
  -Dcom.sun.management.jmxremote.local.only=false \
  -Dcom.sun.management.jmxremote.authenticate=false \
  -Dcom.sun.management.jmxremote.ssl=false \
  -jar xxx.jar

This looks the JDK bug #8023786. Until this is fixed in JDK 7u60, you can run the profiled application with -XX:+StartAttachListener. Some details about this bug are also in this email thread.

I had a similar issue earlier when running a standalone visualvm. Instead, try running the visualvm bundled with the same jdk used to run the application (in my case c:\jdk1.7.0\bin\jvisualvm.exe) and it may not need jmx in the first place.

Anomalocarid

I tried Tomas Hurka's suggestion: add -XX:+StartAttachListener to the run config. I similarly had visualvm hang when connecting to a new debug process.

In my case I was running a JUnit test file. I set a couple of breakpoints in the tests. It turns out that when I click the resume program execution button (fn+F9 in Mac OSX), and stop at a new breakpoint in the tests, visualvm is no longer hanging, and has logged the CPU usage successfully up until that point of execution. (Previously it said CPU usage was not available for my JVM).

I was able to finally start CPU sampling and even calibrate the visualvm profiler from the breakpoint onwards. After pressing resume execution enough times the tests were over and I had a complete snapshot, which I was able to save as csv.

So, for the time being, just set a breakpoint at the earliest sensible line of your code, and make sure you turn on sampling/profiling from then on. Not ideal, but for now better than paying the huge sum for the commercial profilers.

Also, it turns out we are not the only ones with the issue of visualVM hanging, eclipse people have this problem too: Java VisualVM hangs connecting to locally process launched from eclipse

Something to do with proxy usage. Using Cmd+Shift+A and searching network in intelliJ brings this interesting result for me (second search result, below Edit Network options):

'You have JVM property java.net.useSystemProxies set to true. This will cause some network calls to go through operating system-defined proxy. If you didn't intend to use system-defined proxy, disable this property.'

I have not looked further into this avenue, since it seems that I am able to get around the hang in VisualVM by adding -XX:+StartAttachListener to run config and judicious use of breakpoints and the 'resume program execution' button.

For reference, I am using IDEA 14 Community Edition on Retina MBP 2013,OSX Mavericks, and JDK 8, with both Project SDK and VisualVM coming from the same oracle JDK (JDK 8).

I hope this was of some help, it is ridiculous that this issue has lasted nearly 1 year.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!