This is a lightweight, thread-safe memory allocator designed for Windows. It allocates memory in fixed 64-byte blocks within 4MB chunks, using VirtualAlloc
for memory management and atomic bitmaps for tracking block states. The allocator is built with performance and concurrency in mind, featuring minimal locking and safe multi-threaded operation.
- Fixed-size allocation: 64-byte blocks, 4MB chunks.
- Thread safety: Uses
std::atomic
for bitmap updates andstd::mutex
for synchronization. - Efficient memory tracking: Bitmap-based block management (1 bit per block).
- Windows-specific: Relies on
VirtualAlloc
andVirtualFree
. - Unit tests: Comprehensive tests with Google Test, covering single-threaded and multi-threaded scenarios.
- Clone the repository:
git clone https://github.com/Mtfl0n/MemoryAllocator.git
- Build with a C++ compiler supporting C++11 (e.g., MSVC).
MemoryAllocator allocator;
void* ptr = allocator.allocate(); // Allocate a 64-byte block
allocator.deallocate(ptr); // Free the block
///
yes, I know that this is piece of shit, I did this in order to better understand how RAM works =)