Memory Manager

Project for CS280 Low Level Programming class.

Small Introduction

This project had as its purpose giving experience with memory management. I implemented a rudimentary object allocator by applying linked lists. The object allocator was used to allocate and deallocate fixed-sized memory blocks for clients. The idea was to replace the C++ new and delete operators.

Small Introduction

This project had as its purpose giving experience with memory management. I implemented a rudimentary object allocator by applying linked lists. The object allocator was used to allocate and deallocate fixed-sized memory blocks for clients. The idea was to replace the C++ new and delete operators.

At its core, the ObjectAllocator class manages a pool of memory divided into fixed-size blocks. When a client requests memory through the Allocate() method, the allocator provides one of these blocks from a free list. When the client is done with the memory, they call Free() to return it to the free list for reuse. This approach is more efficient than constantly allocating and deallocating from the system because it reuses existing blocks without repeatedly calling the operating system.

The implementation involved managing multiple pages of memory, each containing multiple fixed-size blocks. I used linked lists to track which blocks were available and which were in use. The allocator also needed to handle various scenarios such as running out of memory, validating that freed objects were actually valid allocations, and detecting memory corruption through padding bytes placed around each block. Additionally, I implemented debugging features to help track memory usage and statistics about allocations.