内存扩增,代码定位,一种解决思路
1、命令查看内存中对象的数量
jmap -dump:live,format=b,file=heap-dump.bin
2、jhat命令分析hprof文件
经过漫长的等待后,出现Started HTTP server on port 7000信息时,咱们就可以使用IP+port进行访问了
jhat -J-Xmx9999M heap.hprof
1、查看分析hprof文件,发现内存占用量过大的对象为ConcurrentHashMap。
2、通过jhat查看ConcurrentHashMap的引用对象为Hadoop的Configuration对象。
3、Configuration对象每次初始化都会new ConcurrentHashMap对象。
4、将configuaration对象修改为静态全局变量。
通过java visualVM远程监控jvm
-Djava.rmi.server.hostname=181.181.0.30
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=11099
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false \
安装arthas
wget https://maven.aliyun.com/repository/public/com/taobao/arthas/arthas-packaging/3.1.1/arthas-packaging-3.1.1-bin.zip
…/jdk-11.0.8/bin/java -jar arthas-boot.jar 41197