#memory-allocator #memory #vulkan #allocator #suballocator #tlsf

xalloc

Suballocators for external memory (e.g., Vulkan device memory)

9 releases

Uses old Rust 2015

0.2.7 Dec 9, 2020
0.2.6 Feb 28, 2019
0.2.5 Dec 5, 2018
0.2.4 Nov 7, 2018
0.1.0 Oct 27, 2017

#293 in Memory management

Download history 142/week @ 2024-06-17 107/week @ 2024-06-24 127/week @ 2024-07-01 102/week @ 2024-07-08 50/week @ 2024-07-15 72/week @ 2024-07-22 69/week @ 2024-07-29 79/week @ 2024-08-05 23/week @ 2024-08-12 25/week @ 2024-08-19 51/week @ 2024-08-26 62/week @ 2024-09-02 62/week @ 2024-09-09 60/week @ 2024-09-16 146/week @ 2024-09-23 125/week @ 2024-09-30

398 downloads per month
Used in phosphor

MIT license

93KB
2K SLoC

xalloc

docs.rs

Dynamic suballocators for external memory (e.g., Vulkan device memory).

Provided Algorithms

Generic

Name Time Complexity Space Complexity
TLSF (Two-Level Segregated Fit) O(1) O(N + log size)
Free space bitmap O(size) O(size)

Specialized

Name Time Complexity Space Complexity
Ring buffer O(1) O(N)

(size: heap size measured by the number of allocation units, N: number of allocations)

Examples

use xalloc::{SysTlsf, SysTlsfRegion};
let mut tlsf = xalloc::SysTlsf::new(8u32);

// Allocate regions
let alloc1: (SysTlsfRegion, u32) = tlsf.alloc(4).unwrap();
let alloc2: (SysTlsfRegion, u32) = tlsf.alloc(4).unwrap();
let (region1, offset1) = alloc1;
let (region2, offset2) = alloc2;
println!("allocated #1: {:?}", (&region1, offset1));
println!("allocated #2: {:?}", (&region2, offset2));

// Deallocate a region
tlsf.dealloc(region1).unwrap();

// Now we can allocate again
tlsf.alloc(2).unwrap();
tlsf.alloc(2).unwrap();

Feature Flags

  • nightly — Enables optimizations which currently require a Nightly Rust compiler. This flag is now unused due to the stabilization of NonNull in Rust 1.25.

License: MIT

Dependencies

~485KB