com.sun.grizzly.memory
Interface MemoryManager<E extends Buffer>

All Known Implementing Classes:
ByteBufferManager, ByteBufferViewManager, DefaultMemoryManager, SlabMemoryManagerBase, SlabMemoryManagerImpl, SlabPoolMemoryManagerImpl

public interface MemoryManager<E extends Buffer>

MemoryManager, responsible for allocating and releasing memory, required during application runtime. MemoryManager implementations work with Grizzly Buffers.

Author:
Alexey Stashok
See Also:
Buffer

Method Summary
 E allocate(int size)
          Allocated Buffer of the required size.
 E reallocate(E oldBuffer, int newSize)
          Reallocate Buffer to a required size.
 void release(E buffer)
          Release Buffer.
 

Method Detail

allocate

E allocate(int size)
Allocated Buffer of the required size.

Parameters:
size - Buffer size to be allocated.
Returns:
allocated Buffer.

reallocate

E reallocate(E oldBuffer,
             int newSize)
Reallocate Buffer to a required size. Implementation may choose the way, how reallocation could be done, either by allocating new Buffer of required size and copying old Buffer content there, or perform more complex logic related to memory pooling etc.

Parameters:
oldBuffer - old Buffer to be reallocated.
newSize - new Buffer required size.
Returns:
reallocated Buffer.

release

void release(E buffer)
Release 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.

Parameters:
buffer - Buffer to be released.


Copyright © 2009 SUN Microsystems. All Rights Reserved.