Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jmap tool works only as root and output columns are not clear

Tags:

java

jmap

Using jmap on Ubuntu Mate 18.04-64bits with Oracle JDK 10.0.1-64bits, the tool works only when running both the target and the tool as root, but using the same normal user for running both gives the following error:

Exception in thread "main" com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file /proc/13538/cwd/.attach_pid13538: target process 13538 doesn't respond within 10500ms or HotSpot VM not loaded
at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:103)
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.jmap.JMap.executeCommandForPid(JMap.java:124)
at jdk.jcmd/sun.tools.jmap.JMap.main(JMap.java:114)

When using root user to run the following command

jmap -clstats <pid>

everything works fine but I found some difficulties to understand the meaning of the output columns: enter image description here Is there any official documentation that explains the meaning of each column ?

like image 871
Naruto Biju Mode Avatar asked Jun 22 '18 11:06

Naruto Biju Mode


People also ask

How does jmap work?

The jmap command connects to a running process using the process ID and prints detailed information about classes loaded in the Metaspace: class_loader: The address of the class loader object at the snapshot when the utility was run. classes: The number of classes loaded.

Where is JMAP?

jmap. jmap prints heap dumps into a specified file location. This tool is packaged within JDK. It can be found in \bin folder.


1 Answers

By running this command, one could expect output related to ClassLoaders, but it was modified in JDK8 to print result of jcmd {pid} GC.class_stats command. Some details can be found in JDK-8010507 and JDK-8195682 issues.

As for the output - there is no more documentation than this one. Some description can be found in OpenJDK VM source code, heapInspection.cpp file. I don't find this output too useful, but here some explanation (based on description from this header, and Java class format description):

  • Index: index of this class.
  • Super: index of super class. If -1, then there is no super class (happens for example for array types)
  • InstBytes: number of bytes occupied by all instances of the class (in bytes).
  • KlassBytes: number of bytes occupied by the class itself (in bytes). (Size of the InstanceKlass or ArrayKlass for this class.)
  • annotations: Size of all annotations (in bytes)
  • CpAll: Size of all parts of Constants Pool (Sum of Cp + CpTags + CpCache + CpOperands + CpRefMap)
  • MethodCount: number methods in this class (including constructors)
  • Bytecodes: size occupied by bytecode commands in the class
  • MethodAll: Sum of all space occupied by method and its metadata (MethodBytes + Constmethod + Stackmap + Methoddata)
  • ROAll: Size of all class meta data that could (potentially) be placed in read-only memory. (This could change with CDS design)
  • RWAll: Size of all class meta data that must be placed in read/write memory. (This could change with CDS design)
  • Total: ROAll + RWAll. Note that this does NOT include InstBytes (so no space occupied by instances)
  • ClassName: fully qualified class name.

Hope it helps.

like image 147
AreSo Avatar answered Nov 15 '22 04:11

AreSo