Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.memory

public abstract Class AbstractMemoryManager<E extends Buffer>

extends Object
implements MemoryManager<E extends Buffer>, ThreadLocalPoolProvider
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.memory.ThreadLocalPoolProvider, org.glassfish.grizzly.memory.MemoryManager, org.glassfish.grizzly.monitoring.MonitoringAware
Known Direct Subclasses
org.glassfish.grizzly.memory.ByteBufferManager, org.glassfish.grizzly.memory.HeapMemoryManager
Imports
org.glassfish.grizzly.Buffer, .Cacheable, org.glassfish.grizzly.monitoring.DefaultMonitoringConfig, org.glassfish.grizzly.threadpool.DefaultWorkerThread

A MemoryManager abstraction to provide utilities that may be useful across different MemoryManager implementations.
Since
2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static interface
AbstractMemoryManager.TrimAware

This is a marker interface indicating a particular Buffer implementation can be trimmed.

Field Summary

Modifier and TypeField and Description
public static final int
DEFAULT_MAX_BUFFER_SIZE

The maximum size of the memory pool that is to be maintained by either the MemoryManager itself or any ThreadLocalPools.

protected final int
protected final DefaultMonitoringConfig<MemoryProbe>
monitoringConfig

Basic monitoring support.

Constructor Summary

AccessConstructor and Description
public
AbstractMemoryManager()

Creates a new AbstractMemoryManager using a max buffer size of 65536.

public
AbstractMemoryManager(final int
max size of the maintained buffer.
maxBufferSize
)

Creates a new AbstractMemoryManager using the specified buffer size.

Method Summary

Modifier and TypeMethod and Description
protected Object

Returns:

an memory buffer, or null if the requested size exceeds the remaining free memory of the ThreadLocalPool.
allocateFromPool
(final ThreadLocalPool<E>
the ThreadLocalPool to allocate from.
threadLocalCache
,
final int
the amount to allocate.
size
)

Allocate a Buffer using the provided ThreadLocalPool.

protected abstract Object
createJmxManagementObject()

Returns: the JMX Object used to register/deregister with the JMX runtime.

public int
getMaxBufferSize()

Returns: the max size of the buffer maintained by this AbstractMemoryManager.

public int

Returns:

the size of local thread memory pool.
getReadyThreadBufferSize
()

Get the size of local thread memory pool.

protected static ThreadLocalPool<E>

Returns:

thread associated buffer pool. This method may return null if the current thread doesn't have a buffer pool associated with it.
getThreadLocalPool
()

Get thread associated buffer pool.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_MAX_BUFFER_SIZEback to summary
public static final int DEFAULT_MAX_BUFFER_SIZE

The maximum size of the memory pool that is to be maintained by either the MemoryManager itself or any ThreadLocalPools.

maxBufferSizeback to summary
protected final int maxBufferSize
monitoringConfigback to summary
protected final DefaultMonitoringConfig<MemoryProbe> monitoringConfig

Basic monitoring support. Concrete implementations of this class need only to implement the createJmxManagementObject() method to plug into the Grizzly 2.0 JMX framework.

Constructor Detail

AbstractMemoryManagerback to summary
public AbstractMemoryManager()

Creates a new AbstractMemoryManager using a max buffer size of 65536.

AbstractMemoryManagerback to summary
public AbstractMemoryManager(final int maxBufferSize)

Creates a new AbstractMemoryManager using the specified buffer size.

Parameters
maxBufferSize:int

max size of the maintained buffer.

Method Detail

allocateFromPoolback to summary
protected Object allocateFromPool(final ThreadLocalPool<E> threadLocalCache, final int size)

Allocate a Buffer using the provided ThreadLocalPool.

Parameters
threadLocalCache:ThreadLocalPool<E>

the ThreadLocalPool to allocate from.

size:int

the amount to allocate.

Returns:Object

an memory buffer, or null if the requested size exceeds the remaining free memory of the ThreadLocalPool.

createJmxManagementObjectback to summary
protected abstract Object createJmxManagementObject()
Returns:Object

the JMX Object used to register/deregister with the JMX runtime.

getMaxBufferSizeback to summary
public int getMaxBufferSize()
Returns:int

the max size of the buffer maintained by this AbstractMemoryManager.

getReadyThreadBufferSizeback to summary
public int getReadyThreadBufferSize()

Get the size of local thread memory pool.

Returns:int

the size of local thread memory pool.

getThreadLocalPoolback to summary
protected static ThreadLocalPool<E> getThreadLocalPool()

Get thread associated buffer pool.

Returns:ThreadLocalPool<E>

thread associated buffer pool. This method may return null if the current thread doesn't have a buffer pool associated with it.

org.glassfish.grizzly.memory back to summary

protected Interface AbstractMemoryManager.TrimAware

extends Cacheable
Known Direct Implementers
org.glassfish.grizzly.memory.ByteBufferManager.TrimAwareWrapper, org.glassfish.grizzly.memory.HeapMemoryManager.TrimmableHeapBuffer

This is a marker interface indicating a particular Buffer implementation can be trimmed.

Method Summary

Inherited from org.glassfish.grizzly.Cacheable:
recycle