A custom memory allocator for Go, using arena-style allocation and an optional sharded design for concurrency. It’s a clean, dependency-free implementation focused on speed, predictability, and simple lifetimes (allocate many; free all at once, or via marks).
This project demonstrates:
- bump-pointer arenas (contiguous regions, super fast)
- mmap-backed allocation (large regions)
- thread-safe “safe arena”
- sharded arenas for parallel workloads
- unit tests & benchmarks
- simple demo apps
Note: The earlier guarded arena (debug build with
mprotect) was removed to keep the project simple.
- Arena-based allocation: contiguous region with bump pointer
- Marks & release: reclaim allocations back to a previous point
- Thread-safe mode:
SafeArenawith internal sync - Sharding: multiple arenas for multi-core concurrency
- Typed helpers: allocate typed values and slices
- Zero dependencies: pure Go
- Tests & Benchmarks:
go test,-bench,-benchmem - Makefile: easy build/run/test/bench/fmt/vet/clean
git clone https://github.com/joss12/arena-allocator.git
cd arena-allocator
go mod tidy
go test -bench=. -benchmem