org.apache.cassandra.utils

## Class SlabAllocator

- java.lang.Object
- - org.apache.cassandra.utils.Allocator
  - - org.apache.cassandra.utils.SlabAllocator

    public class SlabAllocator
    extends Allocator

The SlabAllocator is a bump-the-pointer allocator that allocates large (2MB by default) regions and then doles them out to threads that request 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.

### Constructor Summary

Constructors
Constructor and Description
`SlabAllocator()`

### Method Summary

Methods
`java.nio.ByteBuffer` `allocate(int size)`
`long` `getMinimumSize()`

### Methods inherited from class org.apache.cassandra.utils.Allocator

`clone`

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

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

### Constructor Detail

#### SlabAllocator

    public SlabAllocator()

### Method Detail

#### allocate

    public java.nio.ByteBuffer allocate(int size)

Specified by:
  `allocate` in class `Allocator`

#### getMinimumSize

    public long getMinimumSize()

Specified by:
  `getMinimumSize` in class `Allocator`
Returns:
  a lower bound on how much space has been allocated