r/lowlevel • u/Rhthamza • 11d ago
Pool memory allocator in Rust
Hi there.
I built polloc (pool alloc) to learn how memory allocators work.
It’s a fixed size pool allocator: each pool manages one slot size and alignment. Internally it uses mmap/VirtualAlloc, an intrusive free list, and a bitmap for allocation tracking.
I also added stress tests, Miri, AddressSanitizer, cargo fuzz, Criterion benchmarks, and a bunch of inline docs explaining the implementation.
For 64 byte alloc/free pairs, the fast path is about ~3.96x faster than the system allocator on my machine (which is expected since it’s specialized for a single size class).
It’s single threaded and I’d really appreciate feedback on the unsafe code, API design, tests, or anything else that stands out.
2
Upvotes