public abstract class AbstractMemoryManager<E extends Buffer> extends Object implements MemoryManager<E>, ThreadLocalPoolProvider
MemoryManager
abstraction to provide utilities that may be useful
across different MemoryManager
implementations.Modifier and Type | Class and Description |
---|---|
protected static interface |
AbstractMemoryManager.TrimAware
This is a marker interface indicating a particular
Buffer
implementation can be trimmed. |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_BUFFER_SIZE
The maximum size of the memory pool that is to be maintained by
either the MemoryManager itself or any
ThreadLocalPool s. |
protected int |
maxBufferSize |
protected DefaultMonitoringConfig<MemoryProbe> |
monitoringConfig
Basic monitoring support.
|
DEFAULT_MEMORY_MANAGER
Constructor and Description |
---|
AbstractMemoryManager()
Creates a new
AbstractMemoryManager using a max buffer size
of 65536. |
AbstractMemoryManager(int maxBufferSize)
Creates a new
AbstractMemoryManager using the specified
buffer size. |
Modifier and Type | Method and Description |
---|---|
protected Object |
allocateFromPool(ThreadLocalPool threadLocalCache,
int size)
Allocate a
Buffer using the provided ThreadLocalPool . |
protected abstract Object |
createJmxManagementObject() |
int |
getMaxBufferSize() |
int |
getReadyThreadBufferSize()
Get the size of local thread memory pool.
|
protected static ThreadLocalPool |
getThreadLocalPool()
Get thread associated buffer pool.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
allocate, allocateAtLeast, reallocate, release, willAllocateDirect
getMonitoringConfig
createThreadLocalPool
public static final int DEFAULT_MAX_BUFFER_SIZE
ThreadLocalPool
s.protected final DefaultMonitoringConfig<MemoryProbe> monitoringConfig
createJmxManagementObject()
method
to plug into the Grizzly 2.0 JMX framework.protected final int maxBufferSize
public AbstractMemoryManager()
AbstractMemoryManager
using a max buffer size
of 65536.public AbstractMemoryManager(int maxBufferSize)
AbstractMemoryManager
using the specified
buffer size.maxBufferSize
- max size of the maintained buffer.public int getReadyThreadBufferSize()
public int getMaxBufferSize()
AbstractMemoryManager
.protected Object allocateFromPool(ThreadLocalPool threadLocalCache, int size)
Buffer
using the provided ThreadLocalPool
.threadLocalCache
- the ThreadLocalPool
to allocate from.size
- the amount to allocate.null
if the requested size
exceeds the remaining free memory of the ThreadLocalPool
.protected abstract Object createJmxManagementObject()
Object
used to register/deregister with the
JMX runtime.protected static ThreadLocalPool getThreadLocalPool()
null
if the current thread doesn't have a buffer pool
associated with it.Copyright © 2015 Oracle Corporation. All rights reserved.