'Why JCMD throws "native memory tracking is not enabled" message even though NMT is enabled?

I am facing this weird problem. I want to track native memory usage of the JVM. I followed instructions provided in Oracle doc, added NMT enable flag and recycled Tomcat JVM. After that when I tried to see native memory usage using JCMD, I got "native memory tracking is not enabled" message. Do you think I am missing something?

Here is the screen print



Solution 1:[1]

I faced the same issue. Presuming you experienced this issue in linux-like-OS (e.g RHEL); this issue occurs because the OS for security reasons, does not allow any user-id other than the user-id associated with the java-process to connect to the jvm. I had to execute sudo with jcmd command as the process user. In my case, the tomcat-service was executing as "userXXX" user. I was able to get a response from the java process when I executed the cmd below. sudo -u userXXX jcmd {pid} VM.native_memory summary scale=KB

Solution 2:[2]

set -XX:NativeMemoryTracking=detail

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user1523177
Solution 2 WoodX SNiPER