项目作者: yvt

项目描述 :
Dynamic suballocators for external memory (e.g., Vulkan device memory).
高级语言: Rust
项目地址: git://github.com/yvt/xalloc-rs.git
创建时间: 2017-10-27T15:45:33Z
项目社区:https://github.com/yvt/xalloc-rs

开源协议:MIT License

下载


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

  1. use xalloc::{SysTlsf, SysTlsfRegion};
  2. let mut tlsf = xalloc::SysTlsf::new(8u32);
  3. // Allocate regions
  4. let alloc1: (SysTlsfRegion, u32) = tlsf.alloc(4).unwrap();
  5. let alloc2: (SysTlsfRegion, u32) = tlsf.alloc(4).unwrap();
  6. let (region1, offset1) = alloc1;
  7. let (region2, offset2) = alloc2;
  8. println!("allocated #1: {:?}", ion1, offset1));
  9. println!("allocated #2: {:?}", ion2, offset2));
  10. // Deallocate a region
  11. tlsf.dealloc(region1).unwrap();
  12. // Now we can allocate again
  13. tlsf.alloc(2).unwrap();
  14. 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