使用jmap -heap查看详细信息报错
[spark@cs01 ~]$ jmap -heap 24982
Attaching to process ID 24982, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.151-b12
using thread-local object allocation.
Parallel GC with 8 thread(s)
Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 1073741824 (1024.0MB)
NewSize = 174587904 (166.5MB)
MaxNewSize = 357564416 (341.0MB)
OldSize = 349700096 (333.5MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
Exception in thread "main" java.lang.reflect.InvocationTargetException
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: unknown CollectedHeap type : class sun.jvm.hotspot.gc_interface.CollectedHeap
at sun.jvm.hotspot.tools.HeapSummary.run(HeapSummary.java:144)
at sun.jvm.hotspot.tools.Tool.startInternal(Tool.java:260)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:223)
at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
at sun.jvm.hotspot.tools.HeapSummary.main(HeapSummary.java:49)
... 6 more
解决办法, 安装debuuginfo,去网站http://debuginfo.centos.org/7/x86_64找到匹配当前openjdk的版本。
使用wget下载也可以直接下载。
wget http://debuginfo.centos.org/7/x86_64/java-1.8.0-openjdk-debuginfo-1.8.0.151-1.b12.el7_4.x86_64.rpm
查看当前版本信息:
[spark@cs01 test]$ java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
[spark@cs01 test]$ javac -version
javac 1.8.0_151
使用rpm命令安装
rpm -ivh java-1.8.0-openjdk-debuginfo-1.8.0.151-1.b12.el7_4.x86_64.rpm
查看是否安装了debuginfo
[spark@cs01 test]$ rpm -qa|grep debuginfo
glibc-debuginfo-2.17-196.el7_4.2.x86_64
glibc-debuginfo-common-2.17-196.el7_4.2.x86_64
java-1.8.0-openjdk-debuginfo-1.8.0.151-1.b12.el7_4.x86_64
python-debuginfo-2.7.5-58.el7.x86_64
执行jmap -heap
[spark@cs01 test]$ jmap -heap 24982
Attaching to process ID 24982, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.151-b12
using thread-local object allocation.
Parallel GC with 8 thread(s)
Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 1073741824 (1024.0MB)
NewSize = 174587904 (166.5MB)
MaxNewSize = 357564416 (341.0MB)
OldSize = 349700096 (333.5MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 130023424 (124.0MB)
used = 117852296 (112.39270782470703MB)
free = 12171128 (11.607292175292969MB)
90.63928050379599% used
From Space:
capacity = 3145728 (3.0MB)
used = 2784816 (2.6558074951171875MB)
free = 360912 (0.3441925048828125MB)
88.52691650390625% used
To Space:
capacity = 4194304 (4.0MB)
used = 0 (0.0MB)
free = 4194304 (4.0MB)
0.0% used
PS Old Generation
capacity = 716177408 (683.0MB)
used = 284612120 (271.4272689819336MB)
free = 431565288 (411.5727310180664MB)
39.740449338496866% used
17350 interned Strings occupying 1749968 bytes.