Crates.io | polymorph-allocator |
lib.rs | polymorph-allocator |
version | 1.2.0 |
source | src |
created_at | 2019-10-28 07:31:56.735047 |
updated_at | 2020-11-16 05:50:39.944141 |
description | A simple memory allocator |
homepage | https://sr.ht/~ren/polymorphos |
repository | https://git.sr.ht/~ren/polymorph-allocator |
max_upload_size | |
id | 176314 |
size | 32,722 |
A simple Rust memory allocator, designed for polymorphOS.
This crate takes heavy inspiration from awooOS/dmm, a simple C memory allocator for bare-metal uses.
In it's current state, polymorph-allocator
is usable, however it is likely to
be slow for lots of small allocations. This is an artifact of it's design -
every allocation requires iterating through the entire list of allocated chunks
until a free chunk is found.
The next major release of polymorph-allocator
is planned to completely change
how the allocation works, which will improve it's speed, but also it's
complexity. The current version of polymorph-allocator
is rather simple to
understand, and so it could be good as a learning tool. Who knows.
use polymorph_allocator::LockedAllocator;
#[global_allocator]
pub static ALLOCATOR: LockedAllocator = LockedAllocator::empty();
fn main() {
// For a 32MB heap starting at 1MB in RAM:
ALLOCATOR.lock().add_region(0x100000, 0x2000000);
}
polymorph-allocator
is licensed under the MIT License, the same license as
the rest of polymorphOS.
You can find this license in the LICENSE
file in the top level of this
repository.