springboot整合redis报错:OutOfDirectMemoryError
时间:2020-09-02 22:36:04
收藏:0
阅读:621
错误信息
压力测试时产生堆外内存溢出:OutOfDirectMemoryError
原因
- springboot 2.0 以后默认使用
lettuce
作为操作 redis 的客户端,它使用netty
进行通信 - lettuce 的 bug 导致 netty 堆外内存溢出
-Xmx300m
:如果没有指定堆外内存,netty 默认使用堆内存(Xmx)
作为 堆外内存
pom
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
解决
方法一:
不能使用 -Dio.netty.maxDirectMemory 只调大堆外内存
- 升级 lettuce 客户端
- 使用 Jedis(推荐)
pom
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
原文:https://www.cnblogs.com/cnbai/p/13603879.html
评论(0)