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.

相关推荐
aloha_7892 小时前
从零记录搭建一个干净的mybatis环境
java·笔记·spring·spring cloud·maven·mybatis·springboot
毕业设计制作和分享3 小时前
ssm《数据库系统原理》课程平台的设计与实现+vue
前端·数据库·vue.js·oracle·mybatis
paopaokaka_luck6 小时前
基于Spring Boot+Vue的助农销售平台(协同过滤算法、限流算法、支付宝沙盒支付、实时聊天、图形化分析)
java·spring boot·小程序·毕业设计·mybatis·1024程序员节
cooldream20097 小时前
Spring Boot中集成MyBatis操作数据库详细教程
java·数据库·spring boot·mybatis
不像程序员的程序媛8 小时前
mybatisgenerator生成mapper时报错
maven·mybatis
小布布的不10 小时前
MyBatis 返回 Map 或 List<Map>时,时间类型数据,默认为LocalDateTime,响应给前端默认含有‘T‘字符
前端·mybatis·springboot
背水12 小时前
Mybatis基于注解的关系查询
mybatis
free_girl_fang13 小时前
高效作业之Mybatis缓存
java·ide·缓存·mybatis
十二同学啊16 小时前
Mybatis拦截器中获取@RequestBody表单的值修改查询SQL
数据库·sql·mybatis
毕业设计制作和分享17 小时前
ssm好例文共享平台的设计与实现+jsp
java·开发语言·vue.js·spring boot·毕业设计·mybatis