【问题标题】:Redisson memory leak When I try to create clientRedisson内存泄漏当我尝试创建客户端时
【发布时间】:2019-01-15 10:15:28
【问题描述】:

当我尝试使用 Redisson 连接 Redis 服务器时,它有时会显示内存泄漏错误。我该如何解决。 重现代码如下。

预期行为

它不应该有内存泄漏。

实际行为

[main] ERROR io.netty.util.ResourceLeakDetector  - LEAK: HashedWheelTimer.release() was not called before it's garbage-collected. See http://netty.io/wiki/reference-counted-objects.html for more information.
Recent access records: 
Created at:
    io.netty.util.HashedWheelTimer.<init>(HashedWheelTimer.java:272)
    io.netty.util.HashedWheelTimer.<init>(HashedWheelTimer.java:216)
    io.netty.util.HashedWheelTimer.<init>(HashedWheelTimer.java:195)
    org.redisson.connection.MasterSlaveConnectionManager.initTimer(MasterSlaveConnectionManager.java:318)
    org.redisson.connection.MasterSlaveConnectionManager.<init>(MasterSlaveConnectionManager.java:161)
    org.redisson.connection.SingleConnectionManager.<init>(SingleConnectionManager.java:34)
    org.redisson.config.ConfigSupport.createConnectionManager(ConfigSupport.java:192)
    org.redisson.Redisson.<init>(Redisson.java:122)
    org.redisson.Redisson.create(Redisson.java:159)
    test.main(test.java:32)

重现或测试用例的步骤

    Codec stringCodec = new StringCodec();

    for (int i = 0; i < 10; i++) {
        RedissonClient client;
        Config config = new Config();
        config.useSingleServer().setAddress(RedisConfig.Address);
        config.useSingleServer().setPassword(RedisConfig.Password);
        config.setCodec(stringCodec);
        client = Redisson.create(config);

        BatchOptions options = BatchOptions.defaults();
        RBatch pipe = client.createBatch(options);

        pipe.getBucket("test", stringCodec).getAsync();
        BatchResult res = pipe.execute();

        System.out.println(res.getResponses().get(0));

        client.shutdown();

        System.gc();
    }

Redis 版本

4.0.10

Redisson 版本

3.7.5

Redisson 配置

Config config = new Config();
config.useSingleServer().setAddress(RedisConfig.Address);
config.useSingleServer().setPassword(RedisConfig.Password);
config.setCodec(stringCodec);
client = Redisson.create(config);

【问题讨论】:

  • 你应该在他们的图书馆/项目页面上提出这个问题
  • 因为我不知道是我的问题还是图书馆的问题。

标签: java memory-leaks redis netty redisson


【解决方案1】:

这看起来像 Redisson 中的一个错误,它在没有关闭这些的情况下创建了很多 HashedWheelTimer。我会在那里打开一个错误报告。

【讨论】:

    猜你喜欢
    • 2019-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-25
    • 1970-01-01
    相关资源
    最近更新 更多