Crates.io | xalloc |
lib.rs | xalloc |
version | 0.2.7 |
source | src |
created_at | 2017-10-27 16:45:06.171293 |
updated_at | 2020-12-09 12:52:09.868705 |
description | Suballocators for external memory (e.g., Vulkan device memory) |
homepage | |
repository | https://github.com/yvt/xalloc-rs |
max_upload_size | |
id | 37143 |
size | 117,714 |
Dynamic suballocators for external memory (e.g., Vulkan device memory).
Name | Time Complexity | Space Complexity |
---|---|---|
TLSF (Two-Level Segregated Fit) | O(1) |
O(N + log size) |
Free space bitmap | O(size) |
O(size) |
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)
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: {:?}", (®ion1, offset1));
println!("allocated #2: {:?}", (®ion2, offset2));
// Deallocate a region
tlsf.dealloc(region1).unwrap();
// Now we can allocate again
tlsf.alloc(2).unwrap();
tlsf.alloc(2).unwrap();
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