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.ByteBufferallocate(int size)java.nio.ByteBufferallocate(int size, OpOrder.Group opGroup)Clonercloner(OpOrder.Group writeOp)EnsureOnHeapensureOnHeap()voidsetDiscarded()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:
ensureOnHeapin classMemtableAllocator
-
allocate
public java.nio.ByteBuffer allocate(int size)
-
allocate
public java.nio.ByteBuffer allocate(int size, OpOrder.Group opGroup)- Specified by:
allocatein classMemtableBufferAllocator
-
setDiscarded
public void setDiscarded()
Description copied from class:MemtableAllocatorIndicate the memory and resources owned by this allocator are no longer referenced, and can be reclaimed/reused.- Overrides:
setDiscardedin classMemtableAllocator
-
cloner
public Cloner cloner(OpOrder.Group writeOp)
- Specified by:
clonerin classMemtableAllocator
-
-