#allocator #bootstrap #memory-allocator

nightly no-std bsalloc

A simple general-purpose allocator used to bootstrap other allocators

1 unstable release

Uses old Rust 2015

0.1.0 Sep 3, 2017

#25 in #bootstrap


Used in elfmalloc

Apache-2.0

71KB
1K SLoC

bsalloc: a global, no-std dynamic memory allocator.

This crate implements a very simple global allocator. This is used to service heap allocations for dependencies of the dynamic allocators in the rest of the repo. In other words, this is used to bootstrap the more efficient allocators in this repo without creating a needless dependency on another malloc implementation.

Structure

The allocator is a thin wrapper around mmap. Instead of simply calling mmap and munmap for dynamic allocations directly (this did slow things down in some microbenchmarks), we have two "size classes", each with a fixed-size global cache. These caches have a thread-safe interface that allows a thread to efficiently re-use memory freed by it or another thread. Naturally, allocations that are larger than the largest size class fall back on mmap directly.

Dependencies

~235–510KB