首页 > 编程语言 > 详细

springboot整合redis报错:OutOfDirectMemoryError

时间:2020-09-02 22:36:04      阅读:619      评论:0      收藏:0      [点我收藏+]

错误信息

压力测试时产生堆外内存溢出:OutOfDirectMemoryError

原因

  1. springboot 2.0 以后默认使用 lettuce 作为操作 redis 的客户端,它使用 netty 进行通信
  2. lettuce 的 bug 导致 netty 堆外内存溢出
  3. -Xmx300m:如果没有指定堆外内存,netty 默认使用 堆内存(Xmx) 作为 堆外内存

pom

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

解决

方法一:

不能使用 -Dio.netty.maxDirectMemory 只调大堆外内存

  1. 升级 lettuce 客户端
  2. 使用 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>

springboot整合redis报错:OutOfDirectMemoryError

原文:https://www.cnblogs.com/cnbai/p/13603879.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!