public interface MemoryManager<E extends Buffer> extends MonitoringAware<MemoryProbe>
Buffer
s.Buffer
Modifier and Type | Field and Description |
---|---|
static MemoryManager |
DEFAULT_MEMORY_MANAGER
The default
MemoryManager implementation used by all created builder
instances. |
Modifier and Type | Method and Description |
---|---|
E |
allocate(int size)
Allocated
Buffer of the required size. |
E |
allocateAtLeast(int size)
Allocated
Buffer at least of the provided size. |
E |
reallocate(E oldBuffer,
int newSize)
Reallocate
Buffer to a required size. |
void |
release(E buffer)
Release
Buffer . |
boolean |
willAllocateDirect(int size)
Return true if next
allocate(int) or allocateAtLeast(int) call,
made in the current thread for the given memory size, going to return a Buffer based
on direct ByteBuffer , or false otherwise. |
getMonitoringConfig
static final MemoryManager DEFAULT_MEMORY_MANAGER
The default MemoryManager
implementation used by all created builder
instances.
The default may be changed by one of two methods:
DefaultMemoryManagerFactory
interface.
Note that this class must be public and have a public no-arg
constructor.
E allocateAtLeast(int size)
Buffer
at least of the provided size.
This could be useful for usecases like Socket.read(...), where
we're not sure how many bytes are available, but want to read as
much as possible.void release(E buffer)
Buffer
.
Implementation may ignore releasing and let JVM Garbage collector to take
care about the Buffer
, or return Buffer
to pool, in case
of more complex MemoryManager implementation.buffer
- Buffer
to be released.boolean willAllocateDirect(int size)
allocate(int)
or allocateAtLeast(int)
call,
made in the current thread for the given memory size, going to return a Buffer
based
on direct ByteBuffer
, or false otherwise.size
- Copyright © 2015 Oracle Corporation. All rights reserved.