Skip to main content

Crate bomalloc

Crate bomalloc 

Source
Expand description

bomalloc is an experimental, fragmentation-aware allocator.

It can be used through the explicit BoAllocator API or installed as the process allocator through BoGlobalAllocator. The tree carves 64 KiB Black small spans; their steady owner alloc/free path is TLS-only, while cross-thread frees can remain in a bounded TLS Black cache before batched shared publication. OS-backed trim and chunk maintenance remain serialized.

§Platform support

The published crate targets x86-64 Windows and Linux on stable Rust 1.86 or newer. It is experimental and has not received an independent security audit.

§Example

use bomalloc::BoGlobalAllocator;

#[global_allocator]
static GLOBAL: BoGlobalAllocator = BoGlobalAllocator::new();

let values = (0_u64..1_000).collect::<Vec<_>>();
assert_eq!(values.len(), 1_000);

Structs§

BoAllocator
BoCStatsV1
Stable version-1 statistics layout mirrored by include/bomalloc.h.
BoCTrimStatsV1
Stable version-1 trim-result layout mirrored by include/bomalloc.h.
BoGlobalAllocator
A stable GlobalAlloc adapter for using bomalloc as Rust’s process allocator.
Config
InvariantError
StatsSnapshot
TrimStats

Enums§

BoAllocError
TrimMode

Constants§

DEFAULT_DEDICATED_COMMIT_CACHE_BYTES
MAX_ADAPTIVE_RUN_TERRITORY_EXTENSION_EXTENTS
MAX_ADAPTIVE_TERRITORY_EXTENSION_SPANS
MAX_BLACK_SPAN_RING_CAPACITY
MAX_LOCALITY_WINDOW_SPANS
MAX_LOCAL_MAGAZINE_CAPACITY
MAX_LOW_CAPACITY_PAGE_QUEUE_SPANS
MAX_RECENT_FREE_WORD_HINTS
MAX_RECENT_SPANS_PER_CLASS
MAX_REMOTE_CACHE_CAPACITY
MAX_RUN_LOCAL_WINDOW_CAPACITY
SIZE_CLASSES

Functions§

bo_aligned_alloc
bo_allocator_abi_version
bo_allocator_initialize
bo_allocator_stats_v1⚠
Writes the version-1 allocator statistics structure.
bo_allocator_trim_v1⚠
Trims the C allocator and writes the version-1 result structure.
bo_allocator_validate
bo_calloc
bo_free⚠
Releases a pointer returned by bomalloc’s C allocation family.
bo_malloc
bo_malloc_usable_size⚠
Returns the writable byte capacity of a C ABI allocation.
bo_posix_memalign⚠
Stores an aligned allocation in output using POSIX argument rules.
bo_realloc⚠
Resizes an allocation while preserving the common requested prefix.
bo_reallocarray⚠
Overflow-checked array form of bo_realloc.