前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >jmap错误:unknown CollectedHeap type

jmap错误:unknown CollectedHeap type

作者头像
陈灬大灬海
修改2020-11-20 20:34:58
3K0
修改2020-11-20 20:34:58
举报
文章被收录于专栏:面朝大海春暖花开

使用jmap -heap命令查看堆的详细信息报错

Caused by: java.lang.RuntimeException: unknown CollectedHeap type : class sun.jvm.hotspot.gc_interface.CollectedHeap

代码语言:javascript
复制
[root@dahai-java ~]# jmap -heap 27822
Attaching to process ID 27822, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.222-b10

using thread-local object allocation.
Parallel GC with 4 thread(s)

Heap Configuration:
   MinHeapFreeRatio         = 0
   MaxHeapFreeRatio         = 100
   MaxHeapSize              = 1073741824 (1024.0MB)
   NewSize                  = 536870912 (512.0MB)
   MaxNewSize               = 536870912 (512.0MB)
   OldSize                  = 536870912 (512.0MB)
   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:157)
        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:50)
        ... 6 more

奇怪,在本地是没问题的,在linux上却出现这种情况

查看了下jdk版本,都是1.8,没啥问题呀

本地是HotSpot

线上是OpenJDK

最终原因

这里-heap参数会调用用到了sun.jvm下的debug包,而默认openJDK的安装中不包含!

解决方式

下载并安装一个java-openjdk-debug插件!而且需要和openjdk小版本也一致!!!

安装debuginfo

去网站http://debuginfo.centos.org/7/x86_64里面找匹配当前的openjdk的版本,小版本号也要匹配上。

然后使用wget命令下载

代码语言:javascript
复制
wget http://debuginfo.centos.org/7/x86_64/java-1.8.0-openjdk-debuginfo-1.8.0.222.b10-0.el7_6.x86_64.rpm

使用rpm命令安装

代码语言:javascript
复制
rpm -ivh java-1.8.0-openjdk-debuginfo-1.8.0.222.b10-0.el7_6.x86_64.rpm

查看是否安装了debuginfo

代码语言:javascript
复制
[root@dahai-java ~]# rpm -qa|grep debuginfo
java-1.8.0-openjdk-debuginfo-1.8.0.222.b10-0.el7_6.x86_64

再次查询

代码语言:javascript
复制
[root@dahai-java ~]# jmap -heap 27968
Attaching to process ID 27968, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.222-b10

using thread-local object allocation.
Parallel GC with 4 thread(s)

Heap Configuration:
   MinHeapFreeRatio         = 0
   MaxHeapFreeRatio         = 100
   MaxHeapSize              = 2147483648 (2048.0MB)
   NewSize                  = 1073741824 (1024.0MB)
   MaxNewSize               = 1073741824 (1024.0MB)
   OldSize                  = 1073741824 (1024.0MB)
   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 = 1054867456 (1006.0MB)
   used     = 521443544 (497.28731536865234MB)
   free     = 533423912 (508.71268463134766MB)
   49.43213870463741% used
From Space:
   capacity = 8388608 (8.0MB)
   used     = 8377312 (7.989227294921875MB)
   free     = 11296 (0.010772705078125MB)
   99.86534118652344% used
To Space:
   capacity = 9437184 (9.0MB)
   used     = 0 (0.0MB)
   free     = 9437184 (9.0MB)
   0.0% used
PS Old Generation
   capacity = 1073741824 (1024.0MB)
   used     = 334280072 (318.79431915283203MB)
   free     = 739461752 (705.205680847168MB)
   31.132257729768753% used

35880 interned Strings occupying 4018400 bytes.

ok,解决完毕!

遇到的版本问题

我的jdk版本是1.8.0_222-b10,在http://debuginfo.centos.org/7/x86_64找到两个

先下载了个最新的发现并不好使,之后卸载重新下载另一个

rpm卸载

代码语言:javascript
复制
rpm -e --nodeps java-1.8.0-openjdk-debuginfo-1:1.8.0.222.b10-1.el7_7.x86_64

之后重新安装即可

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-09-23 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 本地是HotSpot
  • 线上是OpenJDK
  • 最终原因
  • 解决方式
  • 安装debuginfo
  • rpm卸载
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档