Hi,
We discovered Direct Memory OOM after running program with Ratis for a long
time. Through heap dump, we find DirectByteBuffers holded by
ratis.thirdparty.netty are increasing.
I discovered that in NettyServerStreamRPC.java, newChannelInitializer,
newDecoder, decodeDataStreamRequestByteBuf
static DataStreamRequestByteBuf decodeDataStreamRequestByteBuf(ByteBuf buf) {
return Optional.ofNullable(decodeDataStreamRequestHeader(buf))
.map(header -> checkHeader(header, buf))
.map(header -> new DataStreamRequestByteBuf(header, decodeData(buf,
header, ByteBuf::retain)))
.orElse(null);
}
retain() is called here, but seems no corresponding release(). Since retain()
will add buf's (which is DirectByteBuffer) referenced count, so Cleaner cannot
GC the buf and recycle its corresponding resources. I assume that this might be
the cause of direct memory OOM error, but I’m new to Netty and not certain
about it, so could anyone please take a look at it?
Thanks in advance.
Best Wishes,
William Song