Crate slab_alloc [] [src]

An ObjectAlloc which allocates objects in contiguous slabs and caches constructed objects.


The SlabAlloc is based largely on the slab allocator design originally inroduced in the SunOS 5.4 kernel and described in depth in The Slab Allocator: An Object-Caching Kernel Memory Allocator. This implementation stays somewhat true to the original design, although it includes a number of performance improvements and modifications for user-land.

The SlabAlloc provides a number of performance benefits:

  • As with any ObjectAlloc, object caching reduces the overhead of object initialization in many cases.
  • As with any ObjectAlloc, only needing to allocate objects of a particular size and alignment allows for optimizations not available to general-purpose allocators.
  • Internal and external fragmentation are kept to a minimum.
  • A "coloring" scheme described in Section 4 of the original paper improves cache utilization.



A typed slab allocator.


A builder for SlabAllocs.


An untyped slab allocator.


A builder for UntypedSlabAllocs.



A pair of UntypedObjectAllocs to provide memory for a slab allocator.