mybatis拼接sql导致的oom报错 GC报错

报错1:mybatis拼接过多

java 复制代码
java.lang.OutOfMemoryError: GC overhead limit exceeded

具体报错:

java 复制代码
nested exception is org.apache.ibatis.builder.BuilderException:
Error evaluating expression 'ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere'.
Cause: org.apache.ibatis.ognl.OgnlException: 
sqlSegment [java.lang.OutOfMemoryError: GC overhead limit exceeded

一看报错内容,有builder,expression,sqlSegment,ognl,就可以推测出,应该是mybatis拼接条件太多,导致内存超了。例如条件in里,code太多,或者id太多。

oracle官方对 java.lang.OutOfMemoryError: GC overhead limit exceeded 解释如下:

java 复制代码
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.

大致意思是说:

频繁的进行内存回收(最起码已经进行了5次连续的垃圾回收),JVM就会曝出java.lang.OutOfMemoryError: GC overhead limit exceeded错误。

解决的办法是:

增加堆大小,启动脚本添加参数-Xmx1024m。

或者 关闭GC Overhead limit:-XX:-UseGCOverheadLimit

但由于这是代码本身引起,而非内存不够的问题。所以不建议去改动堆参数或者关闭GC上限。

具体参考

BuilderException OgnlException sqlSegment nonEmptyOfWher OutOfMemoryError:GC overhead limit exceeded_globalcoding的博客-CSDN博客

报错2:

占位符

===================分割线=======================

文章到此已经结束,以下是紫薯补丁

java.lang.OutOfMemoryError: GC overhead limit exceeded

nested exception is org.apache.ibatis.builder.BuilderException:

Error evaluating expression 'ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere'.

Cause: org.apache.ibatis.ognl.OgnlException:

sqlSegment [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.

相关推荐
耀耀_很无聊3 小时前
07_通过 Mybatis 自动填充记录的创建时间和更新时间
mybatis
程序员张34 小时前
SQL分析与打印-p6spy组件
spring boot·sql·mybatis·mybatisplus·p6spy
喜欢敲代码的程序员1 天前
SpringBoot+Mybatis+MySQL+Vue+ElementUI前后端分离版:项目搭建(一)
spring boot·mysql·elementui·vue·mybatis
一只猿Hou1 天前
java分页插件| MyBatis-Plus分页 vs PageHelper分页:全面对比与最佳实践
java·mybatis
java—大象11 天前
基于java SSM的房屋租赁系统设计和实现
java·开发语言·数据库·spring boot·layui·mybatis
Mutig_s11 天前
Spring Boot动态数据源切换:优雅实现多数据源管理
java·数据库·spring boot·后端·mybatis
编程乐学(Arfan开发工程师)11 天前
73、单元测试-断言机制
服务器·数据库·servlet·单元测试·sqlite·log4j·mybatis
小时候的阳光11 天前
MyBatis 的一级缓存导致的数据一致性问题分析
缓存·mybatis·事务·隔离级别
陈嘿萌12 天前
probability tensor contains either `inf`, `nan` or element < 0
报错·模型下载·安装qwen大模型·校验错误