Thanks for discussing this, Mukund. Another difference between the 2 classes is that ElasticByteBufferPool supports a caller's preference for either on-heap or off-heap buffers and internally calls either allocate or allocateDirect. Do you intend to preserve that functionality too in a single merged class?
Chris Nauroth On Wed, Jan 12, 2022 at 1:25 AM Mukund Madhav Thakur <mtha...@cloudera.com.invalid> wrote: > Hello Everyone, > I was just browsing through the code while doing my Vectored IO stuff. It > seems like ElasticByteBufferPool is an ever growing pool and memory is not > getting released as there is no WeakReference being maintained in the pool. > This can cause memory leaks in the production environment. This is widely > used in places like StripedReconstructor, > DFSStripedInputStream, BlockBlobAppendStream etc. > > I would suggest we use DirectBufferPool class for direct buffer pooling as > it already is keeping WeakReference for the buffers. Although, we will have > to make this implement the ByteBufferPool interface and implement the > corresponding methods. Happy to make the API changes once finalized. > > Thanks, > Mukund >