1

I am trying to monitor native memory of tomcat using jcmd but getting following exception: Command: jcmd 14533<pid of tomcat> VM.native_memory summary

I have installed 2 jdk's jdk-11 AND jdk-8.

Tomcat is running by jdk-8 and jcmd used jdk-11 then i got following exception:

com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file /proc/31752/root/tmp/.java_pid31752: target process 31752 doesn't respond within 10500ms or HotSpot VM not loaded
    at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:100)
    at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:58)
    at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
    at jdk.jcmd/sun.tools.jcmd.JCmd.executeCommandForPid(JCmd.java:114)
    at jdk.jcmd/sun.tools.jcmd.JCmd.main(JCmd.java:98)

I attched -XX:+StartAttachListener with java process but it didn't work.

rahul sharma
  • 505
  • 4
  • 17
  • Hope this might help: https://stackoverflow.com/questions/25438983/com-sun-tools-attach-attachnotsupportedexception-unable-to-open-socket-file-ta – Mebin Joe Feb 13 '20 at 09:24

2 Answers2

0

It can be a user permission issue: jmap has to be run with the same user as the java process. e.g. if the owner is usera and this is running in a docker contained execute jmap as user usera

docker exec --user usera -it container_id jmap -dump:format=b,file=/home/usera/memorydump.bin 1
Lorenzo Belli
  • 1,767
  • 4
  • 25
  • 46
0

If you are running tomcat as a service on linux check following config in unit file i.e. tomcat.service

  1. PrivateTmp=yes, should be removed. As PrivateTmp=yes create private /tmp folder which is not accessible by tool
  2. If you have ProtectSystem=strict, add ReadWritePaths=/tmp/

Go through man page for systemd unit file config

Aslam Sayyed
  • 61
  • 1
  • 3