Class DirectByteBufferPool

  • All Implemented Interfaces:

    public class DirectByteBufferPool
    extends Object
    implements ByteBufferPool
    A buffer pool that keeps a free list of ByteBuffers of a specified default size in a simple fixed size stack. If the stack is full, the buffer is de-referenced and available to be freed by normal garbage collection (whenever that may actually take place)
    See Also:
    JDK-4469299, More detail
    • Constructor Detail

      • DirectByteBufferPool

        public DirectByteBufferPool​(int minBufferSize,
                                    int maxPoolSize)
        minBufferSize - the minimum size to create buffers.
        maxPoolSize - the maximum buffers to keep in the pool.
    • Method Detail

      • acquire

        public ByteBuffer acquire​(int size)
        Borrow a buffer from the pool.
        Specified by:
        acquire in interface ByteBufferPool
        size - The minimum size and initial limit of the buffer.
        the buffer.
      • release

        public void release​(ByteBuffer buffer)
        Returns a buffer to the pool.
        Specified by:
        release in interface ByteBufferPool
        buffer - the buffer.