Some NIO channel operations use temporary DirectByteBuffers which are cached in thread-local caches to avoid having to allocate / free a buffer at every operation.
Unfortunately, there is no bound imposed on the size of buffers added to the thread-local caches. So, infrequent channel operations that require a very large buffer can create a native memory leak.
We should introduce a property, jdk.nio.MaxCachedBufferSize that if set sets a limit on the size of the buffers that can be added to the thread-local caches. Operations that require a buffer that is larger than this limit will allocate then free an one-off buffer.