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 (1MiB) global regions and then doles them out to threads that + * request smaller sized (up to 128KiB) 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 Modifier and Type Method Description java.nio.ByteBuffer
allocate(int size)
java.nio.ByteBuffer
allocate(int size, OpOrder.Group opGroup)
Cloner
cloner(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
allocator
-
Methods inherited from class org.apache.cassandra.utils.memory.MemtableAllocator
isLive, offHeap, onHeap, setDiscarding
-
-
-
-
Method Detail
-
ensureOnHeap
public EnsureOnHeap ensureOnHeap()
- Specified by:
ensureOnHeap
in classMemtableAllocator
-
allocate
public java.nio.ByteBuffer allocate(int size)
-
allocate
public java.nio.ByteBuffer allocate(int size, OpOrder.Group opGroup)
- Specified by:
allocate
in classMemtableBufferAllocator
-
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 classMemtableAllocator
-
cloner
public Cloner cloner(OpOrder.Group writeOp)
- Specified by:
cloner
in classMemtableAllocator
-
-