Pooled direct memory increases due to change in ChunkedWriteHandler (Netty 4.1.135)
Hello,
We noticed a problem in our Java web server when we upgraded Netty (previously we were using 4.1.91.Final). We track direct buffer usage and saw a huge spike when we upgraded to 4.1.135.Final. It's not a leak per se since it doesn't continuously increase, but it's still enough to cause problems for us. We tracked this down to https://github.com/netty/netty/pull/13711.
The theory for why this is a problem for us is because we stream data (via HTTPS) to many clients which are unpredictable in speed. Previously, the writes were queued via a new PendingWrite in the ChunkedWriteHandler, but now they are available immediately to downstream handlers (maybe SslHandler) which queue up direct buffers. We also confirmed this commit as the suspect by reverting just that commit and deploying. Below is an image from our test environment showing direct memory metrics before/after this change.
I have a reproducer here -> https://github.com/cfolgere/netty-chunked-write-issue You can run it on any Netty version and see a pass/fail.
Is this intended, and is there any fix or workaround?
Application details: Netty - 4.1.135.Final Netty TC native - 4.1.74.Final OpenSSL - 3.5.x Vert.x - 4.4.1
Source: netty/netty