I get the following error when i try using jmap, jinfo etc and try connecting to a running jvm.
For example
[x@y bin]$ jmap -heap 3848
Attaching to process ID 3848, please wait...
Error attaching to process: java.lang.RuntimeException: can't determine target's VM version : field "_reserve_for_allocation_prefetch" not found in type Abstract_VM_Version
sun.jvm.hotspot.debugger.DebuggerException: java.lang.RuntimeException: can't determine target's VM version : field "_reserve_for_allocation_prefetch" not found in type Abstract_VM_Version
at sun.jvm.hotspot.HotSpotAgent.setupVM(HotSpotAgent.java:435)
at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:305)
at sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:140)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:185)
at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
at sun.jvm.hotspot.tools.HeapSummary.main(HeapSummary.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.tools.jmap.JMap.runTool(JMap.java:201)
at sun.tools.jmap.JMap.main(JMap.java:130)
Caused by: java.lang.RuntimeException: can't determine target's VM version : field "_reserve_for_allocation_prefetch" not found in type Abstract_VM_Version
at sun.jvm.hotspot.runtime.VM.<init>(VM.java:291)
at sun.jvm.hotspot.runtime.VM.initialize(VM.java:370)
at sun.jvm.hotspot.HotSpotAgent.setupVM(HotSpotAgent.java:431)
... 11 more
What could be the problem?
The jmap command being used might be of a version that is lower than the jdk version used to spawn the process.
First check your jdk version
java -version
Then, one can quickly check the jdk version of the jvm by figuring out the launch command for that pid.
ps -p {your_jvm_id} -f
The output should look something like this.
UID PID PPID C STIME TTY TIME CMD
x.y+ 3848 3786 7 Nov18 tty2 20:29:41 /apps/progs/ideaIC-2020.2.3/idea-IC-202.7660.26/jbr/bin/java -classpath /apps/progs/ideaIC-2020.2.3/idea-IC-202.7660.26/lib/bootstrap.jar:/apps/progs/ideaIC-2020.2
In the CMD column, you should see the path of the java executable used to launch the process. Try getting the version of that executable.
For example:
/apps/progs/ideaIC-2020.2.3/idea-IC-202.7660.26/jbr/bin/java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment JBR-11.0.8.10-944.34-jcef (build 11.0.8+10-b944.34)
OpenJDK 64-Bit Server VM JBR-11.0.8.10-944.34-jcef (build 11.0.8+10-b944.34, mixed mode)
Notice the difference between the versions