com.sun.grizzly.memory.slab
Class SlabMemoryManagerFactory

java.lang.Object
  extended by com.sun.grizzly.memory.slab.SlabMemoryManagerFactory

public class SlabMemoryManagerFactory
extends Object

Factory for Allocators (pooled and non-pooled) and SlabPools.

Author:
Ken Cavanaugh

Nested Class Summary
static interface SlabMemoryManagerFactory.SlabPool
          Obtain useful statistics about the SlabPool.
 
Field Summary
static boolean DEFAULT_BYTE_BUFFER_TYPE
           
static long DEFAULT_POOL_MAX_SIZE
          Default max size of which the pool my grow to
static long DEFAULT_POOL_MIN_SIZE
          The default minimum size of the pool in bytes.
static int DEFAULT_SLAB_SIZE
          The default maximum size that can be satisfied by a call to Allocator.allocate().
 
Method Summary
static MemoryManager makeAllocator()
           
static MemoryManager makeAllocator(int allocatorSize, boolean bufferType)
          Return an Allocator that allocates from one slab at a time, creating a new slab as needed.
static SlabMemoryManagerFactory.SlabPool makeDefaultSlabPool()
          Get a SlabPool with defaults
static MemoryManager makePoolAllocator(SlabMemoryManagerFactory.SlabPool pool)
          Create an Allocator that allocates from a pool of slabs.
static SlabMemoryManagerFactory.SlabPool makeSlabPool(int maxAllocationSize, long minSize, long maxSize, boolean bufferType)
          Create a SlabPool from which Allocators may be created.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SLAB_SIZE

public static final int DEFAULT_SLAB_SIZE
The default maximum size that can be satisfied by a call to Allocator.allocate().

See Also:
Constant Field Values

DEFAULT_POOL_MAX_SIZE

public static final long DEFAULT_POOL_MAX_SIZE
Default max size of which the pool my grow to

See Also:
Constant Field Values

DEFAULT_POOL_MIN_SIZE

public static final long DEFAULT_POOL_MIN_SIZE
The default minimum size of the pool in bytes.

See Also:
Constant Field Values

DEFAULT_BYTE_BUFFER_TYPE

public static final boolean DEFAULT_BYTE_BUFFER_TYPE
See Also:
Constant Field Values
Method Detail

makeAllocator

public static MemoryManager makeAllocator(int allocatorSize,
                                          boolean bufferType)
Return an Allocator that allocates from one slab at a time, creating a new slab as needed. Space is recovered by the garbage collector. This version will create a new slab allocator when available space is exhausted. It will only return null if an attempt is made to allocate a BufferWrapper larger than allocatorSize - headerSize bytes. trim is supported, but only for the last BufferWrapper returned from an allocate call.

Parameters:
allocatorSize - The total size available for all allocate calls in a single Allocator.
bufferType - The buffer type of the slabs created for this allocator.
Returns:
MemoryManager

makeAllocator

public static MemoryManager makeAllocator()

makePoolAllocator

public static MemoryManager makePoolAllocator(SlabMemoryManagerFactory.SlabPool pool)
Create an Allocator that allocates from a pool of slabs. All space is managed by the Slabs and SlabPool, and Slabs are recycled once they have been completely freed.

Parameters:
pool - The SlabPool to use for Slabs for this Allocator.
Returns:
MemoryManager

makeSlabPool

public static SlabMemoryManagerFactory.SlabPool makeSlabPool(int maxAllocationSize,
                                                             long minSize,
                                                             long maxSize,
                                                             boolean bufferType)
Create a SlabPool from which Allocators may be created.

Parameters:
maxAllocationSize - The maximum size that can be satisfied by a call to Allocator.allocate().
minSize - The minimum size of the pool in bytes.
maxSize - The maximum size to which a pool may grow.
bufferType - The buffer type used in this pool.

makeDefaultSlabPool

public static SlabMemoryManagerFactory.SlabPool makeDefaultSlabPool()
Get a SlabPool with defaults

Returns:


Copyright © 2009 SUN Microsystems. All Rights Reserved.