0

I am using java visualVM 1.4 to do JDBC profling for my application, i need to do the following: 1-Start profiling 2-Take snapshot 3-Clear profiling records go back to step 1 I need to perform the previous loop for around 10 times, i am using my local-machine to do the entire work. So i do the steps successfully for two times after that either ther visualVM freezes or the java process i am profiling freezes, and my only solution is to restart both process and do the work again. I tried to read logs for visualVM and noticed that i see the following exception:

java.io.IOException: Can not attach to current VM
at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.<init>(HotSpotVirtualMachine.java:75)
at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:58)
at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:58)
at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
at com.sun.tools.visualvm.attach.AttachModelImpl.getVirtualMachine(AttachModelImpl.java:124)
Caused: java.io.IOException: Can not attach to current VM
at com.sun.tools.visualvm.attach.AttachModelImpl.getVirtualMachine(AttachModelImpl.java:126)

I am using jdk 8_152 for both the JVM and the java process.

Baha' Al-Khateib
  • 311
  • 3
  • 13
  • Are you sure you use JDK 8? Your Exception "Can not attach to current VM" was inserted in JDK 9 in the class HotSpotVirtualMachine because of the modular system. In JDK 8 there is no such exception message in this class. With JDK 9 upwards you have to use the ``-jdk.attach.allowAttachSelf=true`` flag to prevent this exception. – Marcel Dec 28 '17 at 07:17
  • @Marcel I am using OracleJDK not open jdk – Baha' Al-Khateib Dec 28 '17 at 09:16

0 Answers0