public class ByteBufferPool extends Object
Constructor and Description |
---|
ByteBufferPool()
Create a default pool of ByteBuffers with 4k capacity
|
ByteBufferPool(int capacity,
boolean direct)
Create a pool of ByteBuffers.
|
Modifier and Type | Method and Description |
---|---|
void |
add(ByteBuffer buffer)
Add a buffer back to the pool.
|
ByteBuffer |
get()
Get a free buffer from the pool.
|
int |
getAllocatedBuffers()
Get the number of buffers currently allocated out.
|
int |
getCapacity()
Get the capacity of buffers in this pool.
|
int |
getFreeBuffers()
Get the number of buffers that are ready to be allocated.
|
long |
getTotalMemoryAllocated()
Calculate the total memory allocated by this pool.
|
long |
getTotalMemoryInUse()
Calculate the total memory in use by this pool.
|
public ByteBufferPool()
public ByteBufferPool(int capacity, boolean direct)
capacity
- intdirect
- booleanpublic int getCapacity()
public int getAllocatedBuffers()
public int getFreeBuffers()
public long getTotalMemoryInUse()
public long getTotalMemoryAllocated()
public ByteBuffer get()
public void add(ByteBuffer buffer)
buffer
- ByteBufferCopyright © 2024. All rights reserved.