Reputation: 840
When I try to use Redisson to Connect Redis Server, it some time show me that memory leak error. how can I fix that. The reproduce code is in below.
It should't have memory leak.
[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();
}
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);
Upvotes: 1
Views: 2443
Reputation: 23567
This looks like a bug in Redisson where it creates a lot of HashedWheelTimer
without closing these. I would open a bug-report there.
Upvotes: 1