Java Web项目内存溢出问题排查

本文介绍了如何排查和解决一个线上Spring Boot项目出现的‘GC overhead limit exceeded’错误。通过分析日志和生成的dump文件,发现可能是由于Kafka连接对象未正确释放导致的内存问题。使用MAT工具进行内存分析,尽管未能直接定位到业务代码,但提示了审查与Kafka相关逻辑的方向,最终在测试连接Kafka的代码中找到了问题并进行了修复。
摘要由CSDN通过智能技术生成

线上的一个spring boot项目每两个周会出现系统卡死,不能正常提供api服务,重启后恢复。经过查看日志发现大量的“java.lang.OutOfMemoryError: GC overhead limit exceeded”日志。这个异常的官方解释:

Exception in thread thread_name: java.lang.OutOfMemoryError: GC Overhead limit exceeded
Cause: The detail message “GC overhead limit exceeded” indicates that the garbage collector is running all the time and Java program is making very slow progress. After a garbage collection, if the Java process is spending more than approximately 98% of its time doing garbage collection and if it is recovering less than 2% of the heap and has been doing so far the last 5 (compile time constant) consecutive garbage collections, then a java.lang.OutOfMemoryError is thrown. This exception is typically thrown because the amount of live data barely fits into the Java heap having little free space for new allocations.
Action: Increase the heap size. The java.lang.OutOfMemoryError exception for GC Overhead limit exceeded can be turned off with the command line flag -XX:-UseGCOverheadLimit.

JVM用了98%的时间进行垃圾回收,而只得到2%可用的内存,频繁的进行内存回收。
结合现象,可以推测程序中某些实例的数量在缓慢的增长,但是一直不能被回收。虽然异常信息不是常见的“java.lang.OutOfMemoryError: Java heap space”,但是原因却是相同的。

那我就开始查找原因吧!先说一下笔者的思路:

1、从生成获取dump文件
2、使用jvisualvm.exe或Eclipse Memory Anal

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值