Systems · 2024
Malloc
A memory allocator written in C with segregated free lists, block splitting, coalescing, and consistency checks.
C · memory management · systems
The problem
A useful allocator has to balance two competing goals: use memory efficiently while still serving allocations quickly.
How it works
I organized free blocks into size classes using segregated free lists, used next-fit placement within those lists, split larger blocks when needed, and coalesced adjacent free blocks to reduce fragmentation.
I also built a heap checker around headers, footers, block boundaries, and free-list consistency so memory corruption could be caught close to where it was introduced.
Outcome
On the course driver, the allocator reached 95% utilization, 92% throughput, and a 0.91 overall score.