redis堆外內存溢出bug


當進行壓力測試時后期后出現堆外內存溢出OutOfDirectMemoryError

產生原因:

1)、springboot2.0以后默認使用lettuce作為操作redis的客戶端,它使用netty進行網絡通信

2)、lettuce的bug導致netty堆外內存溢出。netty如果沒有指定堆外內存,默認使用Xms的值,可以使用-Dio.netty.maxDirectMemory進行設置

解決方案:由於是lettuce的bug造成,不能直接使用-Dio.netty.maxDirectMemory去調大虛擬機堆外內存,治標不治本。

1)、升級lettuce客戶端。但是沒有解決的
2)、切換使用jedis

<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>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM