| Crates.io | lite-alloc |
| lib.rs | lite-alloc |
| version | 0.1.0 |
| created_at | 2025-12-19 19:31:40.383076+00 |
| updated_at | 2025-12-19 19:31:40.383076+00 |
| description | A lightweight, single-threaded memory allocator designed for WebAssembly and embedded systems. |
| homepage | https://github.com/ShaoG-R/lite-alloc |
| repository | https://github.com/ShaoG-R/lite-alloc |
| max_upload_size | |
| id | 1995377 |
| size | 116,110 |
Lite Alloc is a lightweight, single-threaded memory allocator library for Rust, specifically designed for WebAssembly (Wasm) and embedded systems. It focuses on minimizing code size (binary footprint) and maximizing performance in single-threaded environments.
Warning: These allocators are single-threaded. While they implement
Syncto satisfy theGlobalAlloctrait, using them in a multi-threaded environment will result in Undefined Behavior (UB). Use them only in environments typically known to be single-threaded, such as Wasm or specific embedded targets.Note: This project is currently experimental. While core functionality is implemented, it has not yet undergone comprehensive test coverage. Please test thoroughly before using in production environments.
Lite Alloc provides three distinct allocator implementations, allowing you to choose the best trade-off between code size, performance, and memory efficiency for your specific use case.
BumpFreeListAllocatorA minimalist allocator combining a Bump Pointer with an unsorted Free List.
SegregatedBumpAllocatorA hybrid allocator using Segregated Free Lists (Bins) for small objects and a Bump Pointer for large objects.
FreeListAllocatorA general-purpose allocator using a sorted linked list with block coalescing.
Add lite-alloc to your Cargo.toml.
[dependencies]
lite-alloc = "0.1.0"
To use one of the allocators as your global allocator in a no_std / Wasm project:
use lite_alloc::single_threaded::BumpFreeListAllocator;
#[global_allocator]
static ALLOCATOR: BumpFreeListAllocator = BumpFreeListAllocator::new();
fn main() {
// Your code here
}
Or choose another strategy:
use lite_alloc::single_threaded::{FreeListAllocator, SegregatedBumpAllocator};
// Use FreeListAllocator for general purpose
#[global_allocator]
static ALLOCATOR: FreeListAllocator = FreeListAllocator::new();
// OR Use SegregatedBumpAllocator for tiny tasks
// #[global_allocator]
// static ALLOCATOR: SegregatedBumpAllocator = SegregatedBumpAllocator::new();
This project is licensed under the MIT License. See the LICENSE file for details.