question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LEAK: ByteBuf.release() was not called before it's garbage-collected.

See original GitHub issue

Redisson 3.5.1

I am debugging why we are seeing ByteBuf leaks and native memory problems. I suspect one reason could be serialization failing for some objects.

I created a simple test to run this code in a loop Object MY_DUMMY_NON_SERIALIZABLE_OBJECT = Logger.getGlobal(); redisson.getMap(“cacheMap”).fastPut(“value”, MY_DUMMY_NON_SERIALIZABLE_OBJECT );

The code triggers: java.lang.IllegalArgumentException: java.io.NotSerializableException: java.util.logging.Logger and looks like MarshallingCodec. Encoder.encode doesn’t clean the ByteBuf if there is an exception - and I don’t see a way to do it myself.

I enabled -Dio.netty.leakDetectionLevel=paranoid to get this output:

SEVERE: LEAK: ByteBuf.release() was not called before it's garbage-collected. See https://netty.io/wiki/reference-counted-objects.html for more information.
Recent access records: 
#1:
	io.netty.buffer.AdvancedLeakAwareByteBuf.writeBytes(AdvancedLeakAwareByteBuf.java:616)
	org.redisson.codec.MarshallingCodec$ByteOutputWrapper.write(MarshallingCodec.java:131)
	org.jboss.marshalling.UTFUtils.writeUTFBytes(UTFUtils.java:131)
	org.jboss.marshalling.river.RiverMarshaller.writeKnownObject(RiverMarshaller.java:397)
	org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:217)
	org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)
	org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)
	org.redisson.codec.MarshallingCodec$4.encode(MarshallingCodec.java:170)
	org.redisson.command.CommandAsyncService.encodeMapKey(CommandAsyncService.java:725)
	org.redisson.RedissonObject.encodeMapKey(RedissonObject.java:301)
	org.redisson.RedissonMap.fastPutOperationAsync(RedissonMap.java:1375)
	org.redisson.RedissonMap.fastPutAsync(RedissonMap.java:1365)
	org.redisson.RedissonMap.fastPut(RedissonMap.java:1380)
	adhoc.testing.RedissonMemoryTest.main(RedissonMemoryTest.java:53)
#2:
	io.netty.buffer.AdvancedLeakAwareByteBuf.writeBytes(AdvancedLeakAwareByteBuf.java:616)
	org.redisson.codec.MarshallingCodec$ByteOutputWrapper.write(MarshallingCodec.java:131)
	org.jboss.marshalling.SimpleDataOutput.shallowFlush(SimpleDataOutput.java:353)
	org.jboss.marshalling.river.RiverMarshaller.writeKnownObject(RiverMarshaller.java:396)
	org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:217)
	org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)
	org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)
	org.redisson.codec.MarshallingCodec$4.encode(MarshallingCodec.java:170)
	org.redisson.command.CommandAsyncService.encodeMapKey(CommandAsyncService.java:725)
	org.redisson.RedissonObject.encodeMapKey(RedissonObject.java:301)
	org.redisson.RedissonMap.fastPutOperationAsync(RedissonMap.java:1375)
	org.redisson.RedissonMap.fastPutAsync(RedissonMap.java:1365)
	org.redisson.RedissonMap.fastPut(RedissonMap.java:1380)
	adhoc.testing.RedissonMemoryTest.main(RedissonMemoryTest.java:53)
Created at:
	io.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:385)
	io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:187)
	io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:173)
	io.netty.buffer.AbstractByteBufAllocator.buffer(AbstractByteBufAllocator.java:107)
	org.redisson.codec.MarshallingCodec$4.encode(MarshallingCodec.java:165)
	org.redisson.command.CommandAsyncService.encodeMapKey(CommandAsyncService.java:725)
	org.redisson.RedissonObject.encodeMapKey(RedissonObject.java:301)
	org.redisson.RedissonMap.fastPutOperationAsync(RedissonMap.java:1375)
	org.redisson.RedissonMap.fastPutAsync(RedissonMap.java:1365)
	org.redisson.RedissonMap.fastPut(RedissonMap.java:1380)
	adhoc.testing.RedissonMemoryTest.main(RedissonMemoryTest.java:53)

If I can’t get the native memory issues sorted out, I need to see if this can help: -Dio.netty.noPreferDirect=true -Dio.netty.allocator.type=unpooled

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
boot-vuecommented, Apr 20, 2021

I hava the problem also.

0reactions
mrnikocommented, May 5, 2021

@anabright

That fix already included in 3.15.3

Read more comments on GitHub >

github_iconTop Results From Across the Web

LEAK: ByteBuf.release() was not called before it's garbage ...
You need to call release on the ByteBuf rather than clear in your finally block, otherwise the reference counted buffer is not de-allocated...
Read more >
LEAK: ByteBuf.release() was not called before it's garbage ...
LEAK : ByteBuf.release() was not called before it's garbage-collected. LEAK: ByteBuf.release() was not called before it's garbage-collected.
Read more >
LEAK: ByteBuf.release() was not called before it's garbage ...
After some time collecting data from a modbus TCP device we get the error: 16:29:50.228 ERROR ResourceLeakDetector: LEAK: ByteBuf.release() ...
Read more >
LEAK: ByteBuf.release() was not called before it's garbage ...
I have a single-type es node , the es node is runing by docker contianer. Host Version: CentOS 8.3 x64. Docker Version: 20.10.5....
Read more >
ByteBuf.release() was not called before it's garbage-collected
ResourceLeakDetector - LEAK: ByteBuf.release() was not called before it's garbage-collected. Recent access records: 1 #1: io.netty.buffer.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found