Module org.glassfish.grizzly
Package org.glassfish.grizzly.memory
Class AbstractMemoryManager<E extends Buffer>
java.lang.Object
org.glassfish.grizzly.memory.AbstractMemoryManager<E>
- All Implemented Interfaces:
MemoryManager<E>,ThreadLocalPoolProvider,MonitoringAware<MemoryProbe>
- Direct Known Subclasses:
ByteBufferManager,HeapMemoryManager
public abstract class AbstractMemoryManager<E extends Buffer>
extends Object
implements MemoryManager<E>, ThreadLocalPoolProvider
A
MemoryManager abstraction to provide utilities that may be useful across different MemoryManager
implementations.- Since:
- 2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceThis is a marker interface indicating a particularBufferimplementation can be trimmed. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum size of the memory pool that is to be maintained by either the MemoryManager itself or anyThreadLocalPools.protected final intprotected final DefaultMonitoringConfig<MemoryProbe>Basic monitoring support.Fields inherited from interface org.glassfish.grizzly.memory.MemoryManager
DEFAULT_MEMORY_MANAGER -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newAbstractMemoryManagerusing a max buffer size of 65536.AbstractMemoryManager(int maxBufferSize) Creates a newAbstractMemoryManagerusing the specified buffer size. -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectallocateFromPool(ThreadLocalPool threadLocalCache, int size) Allocate aBufferusing the providedThreadLocalPool.protected abstract ObjectintintGet the size of local thread memory pool.protected static ThreadLocalPoolGet thread associated buffer pool.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.glassfish.grizzly.memory.MemoryManager
allocate, allocateAtLeast, reallocate, release, willAllocateDirectMethods inherited from interface org.glassfish.grizzly.monitoring.MonitoringAware
getMonitoringConfigMethods inherited from interface org.glassfish.grizzly.memory.ThreadLocalPoolProvider
createThreadLocalPool
-
Field Details
-
DEFAULT_MAX_BUFFER_SIZE
public static final int DEFAULT_MAX_BUFFER_SIZEThe maximum size of the memory pool that is to be maintained by either the MemoryManager itself or anyThreadLocalPools.- See Also:
-
monitoringConfig
Basic monitoring support. Concrete implementations of this class need only to implement thecreateJmxManagementObject()method to plug into the Grizzly 2.0 JMX framework. -
maxBufferSize
protected final int maxBufferSize
-
-
Constructor Details
-
AbstractMemoryManager
public AbstractMemoryManager()Creates a newAbstractMemoryManagerusing a max buffer size of 65536. -
AbstractMemoryManager
public AbstractMemoryManager(int maxBufferSize) Creates a newAbstractMemoryManagerusing the specified buffer size.- Parameters:
maxBufferSize- max size of the maintained buffer.
-
-
Method Details
-
getReadyThreadBufferSize
public int getReadyThreadBufferSize()Get the size of local thread memory pool.- Returns:
- the size of local thread memory pool.
-
getMaxBufferSize
public int getMaxBufferSize()- Returns:
- the max size of the buffer maintained by this
AbstractMemoryManager.
-
allocateFromPool
Allocate aBufferusing the providedThreadLocalPool.- Parameters:
threadLocalCache- theThreadLocalPoolto allocate from.size- the amount to allocate.- Returns:
- an memory buffer, or
nullif the requested size exceeds the remaining free memory of theThreadLocalPool.
-
createJmxManagementObject
- Returns:
- the JMX
Objectused to register/deregister with the JMX runtime.
-
getThreadLocalPool
Get thread associated buffer pool.- Returns:
- thread associated buffer pool. This method may return
nullif the current thread doesn't have a buffer pool associated with it.
-