public class DirectByteBufferPool extends java.lang.Object implements BufferPool
A buffer pool which keeps a free list of direct buffers 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.
Using a direct ByteBuffer when dealing with NIO operations has been proven to be faster than wrapping on-heap Arrays. There is ultimately no performance benefit to wrapping in-heap JVM data when writing with NIO.
Constructor and Description |
---|
DirectByteBufferPool(int defaultBufferSize,
int maxPoolEntries) |
Modifier and Type | Method and Description |
---|---|
java.nio.ByteBuffer |
acquire() |
void |
release(java.nio.ByteBuffer buf) |
public DirectByteBufferPool(int defaultBufferSize, int maxPoolEntries)
public java.nio.ByteBuffer acquire()
acquire
in interface BufferPool
public void release(java.nio.ByteBuffer buf)
release
in interface BufferPool