| Crates.io | memory-pool-allocator |
| lib.rs | memory-pool-allocator |
| version | 1.0.2 |
| created_at | 2025-06-24 11:19:59.349087+00 |
| updated_at | 2025-10-25 10:45:48.605838+00 |
| description | A fixed-size, thread-safe memory pool allocator for Rust, supporting custom chunk sizes and efficient allocation/deallocation. |
| homepage | |
| repository | https://github.com/Chirping666/memory-pool-allocator |
| max_upload_size | |
| id | 1724173 |
| size | 54,755 |
A fixed-size, thread-safe memory pool allocator for Rust, supporting custom chunk sizes and efficient allocation/deallocation. Made with the help of AI such as Claude and Copilot.
parking_lot::Mutexrust *mut u8 )zero-on-free, zero-on-drop and statistics.Add to your Cargo.toml:
[dependencies]
memory-pool-allocator = "1.0"
Or, if you do not want statistics and zeroing, add:
[dependencies]
memory-pool-allocator = { version = "1.0", default-features = false }
Example:
use memory_pool_allocator::MemoryPoolAllocator;
use core::alloc::Layout;
#[repr(align(64))]
struct Aligned {
mem: [u8; 1024]
}
let mut aligned = Aligned { mem: [0; 1024] };
let allocator = unsafe { MemoryPoolAllocator::<1024, 64>::new(aligned.mem.as_mut_ptr()) };
let layout = Layout::from_size_align(128, 64).unwrap();
let ptr = allocator.try_allocate(layout).unwrap();
assert_eq!(ptr as usize % 64, 0);
allocator.try_deallocate(ptr).unwrap();
N bytes, aligned to the maximum alignment required by allocations.N (total bytes) must be exactly divisible by M (number of chunks).Licensed under either of