当我尝试使用 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
雷迪森版本
3.7.5
雷迪森配置
Config config = new Config();
config.useSingleServer().setAddress(RedisConfig.Address);
config.useSingleServer().setPassword(RedisConfig.Password);
config.setCodec(stringCodec);
client = Redisson.create(config);