org.apache.cassandra.utils.memory

## Class SlabAllocator

- java.lang.Object
- - org.apache.cassandra.utils.memory.MemtableAllocator
  - - org.apache.cassandra.utils.memory.MemtableBufferAllocator
    - - org.apache.cassandra.utils.memory.SlabAllocator

    public class SlabAllocator
    extends MemtableBufferAllocator

+ * The SlabAllocator is a bump-the-pointer allocator that allocates + * large (1MB) global regions and then doles them out to threads that + * request smaller sized (up to 128kb) slices into the array.

The purpose of this class is to combat heap fragmentation in long lived objects: by ensuring that all allocations with similar lifetimes only to large regions of contiguous memory, we ensure that large blocks get freed up at the same time.

Otherwise, variable length byte arrays allocated end up interleaved throughout the heap, and the old generation gets progressively more fragmented until a stop-the-world compacting collection occurs.

### Nested Class Summary

### Nested classes/interfaces inherited from class org.apache.cassandra.utils.memory.MemtableAllocator

`MemtableAllocator.SubAllocator`

### Method Summary

All Methods Instance Methods Concrete Methods
`java.nio.ByteBuffer` `allocate(int size)`
`java.nio.ByteBuffer` `allocate(int size, OpOrder.Group opGroup)`
`protected AbstractAllocator` `allocator(OpOrder.Group writeOp)`
`EnsureOnHeap` `ensureOnHeap()`
`void` `setDiscarded()` Indicate the memory and resources owned by this allocator are no longer referenced, and can be reclaimed/reused.

### Methods inherited from class org.apache.cassandra.utils.memory.MemtableBufferAllocator

`clone, rowBuilder`

### Methods inherited from class org.apache.cassandra.utils.memory.MemtableAllocator

`isLive, offHeap, onHeap, setDiscarding`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### ensureOnHeap

    public EnsureOnHeap ensureOnHeap()

Specified by:
  `ensureOnHeap` in class `MemtableAllocator`

#### allocate

    public java.nio.ByteBuffer allocate(int size)

#### allocate

    public java.nio.ByteBuffer allocate(int size,
                                        OpOrder.Group opGroup)

Specified by:
  `allocate` in class `MemtableBufferAllocator`

#### setDiscarded

    public void setDiscarded()

Description copied from class: `MemtableAllocator`
Indicate the memory and resources owned by this allocator are no longer referenced, and can be reclaimed/reused.

Overrides:
  `setDiscarded` in class `MemtableAllocator`

#### allocator

    protected AbstractAllocator allocator(OpOrder.Group writeOp)

Overrides:
  `allocator` in class `MemtableBufferAllocator`