Head-First Memory Allocation on Best-Fit with Space-Fitting
Adam Noto Hakarsa
TL;DR
The paper addresses the slowdown of best-fit memory allocation by introducing a head-first memory layout that keeps the free region at the head of memory, achieving around $34.86\%$ faster allocation/deallocation while keeping external fragmentation low. The allocator uses a compact per-block header and integrates SpaceFit, ChunkUp, and Stitch to manage space and coalescing, with allocation guided by a Create function and a head-first variant that avoids traversal. Benchmarking on synthetic workloads shows substantial speedups with head-first compared to non-head-first, without sacrificing allocation success or fragmentation control. This layout-level optimization offers practical performance gains for dynamic memory management and could generalize to other allocation strategies in real-world systems.
Abstract
Although best-fit is known to be slow, it excels at optimizing memory space utilization. Interestingly, by keeping the free memory region at the top of the memory, the process of memory allocation and deallocation becomes approximately 34.86% faster while also maintaining external fragmentation at minimum.
