public final class ChunkPool extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
ByteBuffer |
allocate(int size,
long maxTimeToBlockMs)
从空闲池分配给定大小的缓冲区。
|
long |
availableMemory()
未分配的和空闲列表中的总空闲内存
|
void |
clear()
释放内存池
|
void |
deallocate(ByteBuffer buffer) |
void |
deallocate(ByteBuffer buffer,
int size)
将缓冲区返回到池。
|
int |
queued()
等待内存时阻塞的线程数
|
long |
totalMemory()
此池管理的总内存
|
long |
unallocatedMemory()
获取未分配的内存(不在空闲列表中或正在使用中)
|
public ChunkPool(long memory,
Time time,
boolean direct)
memory - 内存池总大小time - 等待时间direct - 是否堆内存public ByteBuffer allocate(int size, long maxTimeToBlockMs) throws InterruptedException, TimeoutException
size - 以字节为单位分配的缓冲区大小maxTimeToBlockMs - 缓冲区内存分配的最大阻塞时间(以毫秒为单位)InterruptedException - 异常TimeoutException - 异常public void deallocate(ByteBuffer buffer, int size)
buffer - 要释放的缓冲区size - 要标记为释放的缓冲区的大小,注意这可能小于buffer.capacity,因为缓冲区可能在就地压缩期间重新分配自己public void deallocate(ByteBuffer buffer)
public long availableMemory()
public long unallocatedMemory()
public int queued()
public void clear()
public long totalMemory()
Copyright © 2021. All rights reserved.