|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.grizzly.memory.ByteBufferManager
org.glassfish.grizzly.memory.ByteBufferViewManager
org.glassfish.grizzly.memory.DefaultMemoryManager
public class DefaultMemoryManager
Default MemoryManager, used in Grizzly.
DefaultMemory has simple Buffer pooling implementation,
which makes released Buffer's memory to be reused.
| Nested Class Summary | |
|---|---|
class |
DefaultMemoryManager.BufferInfo
Information about thread associated memory pool. |
class |
DefaultMemoryManager.TrimAwareWrapper
ByteBufferWrapper implementation, which supports triming. |
| Field Summary | |
|---|---|
static int |
DEFAULT_MAX_BUFFER_SIZE
|
| Fields inherited from class org.glassfish.grizzly.memory.ByteBufferViewManager |
|---|
capacity, DEFAULT_CAPACITY, largeByteBuffer |
| Fields inherited from class org.glassfish.grizzly.memory.ByteBufferManager |
|---|
isDirect |
| Constructor Summary | |
|---|---|
DefaultMemoryManager()
|
|
| Method Summary | |
|---|---|
ByteBufferWrapper |
allocate(int size)
Allocates Buffer of required size. |
int |
getMaxThreadBufferSize()
Get the maximum size of memory pool for one thread. |
int |
getReadyThreadBufferSize()
Get the size of local thread memory pool. |
long |
getTotalBytesAllocated()
Get real number of bytes allocated by this MemoryManager. |
boolean |
isMonitoring()
Is monotoring enabled. |
ByteBufferWrapper |
reallocate(ByteBufferWrapper oldBuffer,
int newSize)
Reallocate Buffer to a required size. |
void |
release(ByteBufferWrapper buffer)
Release Buffer. |
void |
setMaxThreadBufferSize(int maxThreadBufferSize)
Set the maximum size of memory pool for one thread. |
void |
setMonitoring(boolean isMonitoring)
Set monotoring mode. |
ByteBufferWrapper |
wrap(ByteBuffer byteBuffer)
Returns Buffer, which wraps the ByteBuffer. |
| Methods inherited from class org.glassfish.grizzly.memory.ByteBufferViewManager |
|---|
slice |
| Methods inherited from class org.glassfish.grizzly.memory.ByteBufferManager |
|---|
allocate0, isDirect, setDirect, wrap, wrap, wrap, wrap |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_MAX_BUFFER_SIZE
| Constructor Detail |
|---|
public DefaultMemoryManager()
| Method Detail |
|---|
public int getMaxThreadBufferSize()
public void setMaxThreadBufferSize(int maxThreadBufferSize)
maxThreadBufferSize - the maximum size of memory pool for one thread.public boolean isMonitoring()
public void setMonitoring(boolean isMonitoring)
isMonitoring - true, if monitoring is enabled, or
false otherwise.public long getTotalBytesAllocated()
MemoryManager.
It doesn't count bytes, which were pooled and then reused.
MemoryManager.public ByteBufferWrapper allocate(int size)
Buffer of required size.
First of all DefaultMemoryManager tries to reuse thread local
memory pool. If it's not possible - it delegates allocation to
ByteBufferViewManager.
allocate in interface MemoryManager<ByteBufferWrapper>allocate in class ByteBufferViewManagersize - number of bytes to be allocated.
ByteBufferWrapper.
public ByteBufferWrapper reallocate(ByteBufferWrapper oldBuffer,
int newSize)
Buffer to a required size.
First of all DefaultMemoryManager tries to reuse thread local
memory pool. If it's not possible - it delegates reallocation to
ByteBufferViewManager.
reallocate in interface MemoryManager<ByteBufferWrapper>reallocate in class ByteBufferViewManageroldBuffer - old Buffer we want to reallocate.newSize - Buffer required size.
Buffer.public void release(ByteBufferWrapper buffer)
Buffer.
DefaultMemoryManager will checks if it's possible to return
the buffer to thread local pool. If not - let's garbage collector utilize
the memory.
release in interface MemoryManager<ByteBufferWrapper>release in class ByteBufferManagerbuffer - Buffer to be released.public int getReadyThreadBufferSize()
public ByteBufferWrapper wrap(ByteBuffer byteBuffer)
ByteBufferManagerBuffer, which wraps the ByteBuffer.
wrap in interface WrapperAware<ByteBufferWrapper>wrap in class ByteBufferManagerbyteBuffer - ByteBuffer to wrap
Buffer wrapper on top of passed ByteBuffer.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||