A fixed-size memory pool implemented in C++17 that efficiently handles frequent allocations and deallocations of many small objects. It uses bucketed fixed-size pools, chunk-based bulk allocation, and an intrusive free list for fast O(1)-like operations.
mkdir build
cd build
cmake ..
cmake --build .
# Run:
# Linux/macOS: ./test_exe
# Windows: test_exe.exeTip: to switch build type, pass -DCMAKE_BUILD_TYPE=Debug to cmake.
ALIGNMENTandalignasensure proper memory alignment.RoundUp/GetBucketIndexdetermine the bucket for a requested size.scoped_allocate<T>returns astd::unique_ptrwith a custom deleter to automatically free memory.allocate_new_chunk()allocates raw memory withoperator newand partitions it into fixed-size blocks.reinterpret_castis used when convertingchar*toFreeBlock*; ensure alignment correctness.
src/test.cpp contains a simple test that:
- exercises
scoped_allocate(RAII) and allocations of different sizes; - prints allocation addresses and asserts non-null pointers.
Issues and pull requests are very welcome. If you encounter problems or have questions, please open an issue — we aim to respond promptly.
MIT License