https://github.com/yvt/xalloc-rs
Dynamic suballocators for external memory (e.g., Vulkan device memory). Umaintained - consider migrating to https://crates.io/crates/offset-allocator
https://github.com/yvt/xalloc-rs
directx-12 memory-allocator rust tlsf vulkan
Last synced: 11 months ago
JSON representation
Dynamic suballocators for external memory (e.g., Vulkan device memory). Umaintained - consider migrating to https://crates.io/crates/offset-allocator
- Host: GitHub
- URL: https://github.com/yvt/xalloc-rs
- Owner: yvt
- License: mit
- Created: 2017-10-27T15:45:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-07-22T02:26:40.000Z (over 3 years ago)
- Last Synced: 2025-04-02T21:40:22.234Z (11 months ago)
- Topics: directx-12, memory-allocator, rust, tlsf, vulkan
- Language: Rust
- Homepage: https://crates.io/crates/xalloc
- Size: 56.6 KB
- Stars: 15
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# xalloc
[
](https://docs.rs/xalloc/)
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
```rust
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();
```
## 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.
[stabilization]: https://blog.rust-lang.org/2018/03/29/Rust-1.25.html
License: MIT