Crate slabmalloc_safe
source ·Expand description
A slab allocator implementation for objects less than 8KiB.
This allocator uses only safe Rust and associates an AllocablePages
’s lifetime with its MappedPages
object.
The only way to achieve this is to store the MappedPages in statically sized buffers (Page Lists),
so the heap size is set at compile time and cannot grow.
Additional pages cannot be added when an OOM error occurs.
Overview
The organization is as follows:
- A
ZoneAllocator
manages manySCAllocator
and can satisfy requests for different allocation sizes. - A
SCAllocator
allocates objects of exactly one size. It stores the objects and meta-data in one or multipleAllocablePage
objects. - A trait
AllocablePage
that defines the page-type from which we allocate objects.
Lastly, it provides a default AllocablePage
implementations ObjectPage8k
that is 8 KiB in size
and contains allocated objects and associated meta-data
Structs
- A wrapper type around MappedPages which ensures that the MappedPages have a size and alignment of 8 KiB and are writable.
- Holds allocated data within 2 4-KiB pages.
- A zone allocator for arbitrary sized allocations.
Traits
- This trait is used to define a page from which objects are allocated in an
SCAllocator
.