Crates.io | bsalloc |
lib.rs | bsalloc |
version | 0.1.0 |
source | src |
created_at | 2017-09-03 01:34:42.966077 |
updated_at | 2017-09-03 01:34:42.966077 |
description | A simple general-purpose allocator used to bootstrap other allocators. |
homepage | |
repository | https://github.com/ezrosent/allocators-rs/tree/master/bsalloc |
max_upload_size | |
id | 30336 |
size | 9,824 |
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.
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.