Heap Fragmentation
Heap fragmentation is the condition in which a heap contains sufficient total free memory to satisfy an allocation request, but the free memory is divided into blocks too small to be usable. Fragmentation is the dominant long-term pathology of dynamic memory allocation, and it is the reason that simple allocators fail under sustained workloads. There are two forms: external fragmentation, in which free blocks are scattered among allocated blocks, and internal fragmentation, in which allocated blocks are larger than requested, wasting space inside each block. Both forms increase the entropy of the heap's state, requiring more complex allocator data structures and more CPU cycles to manage. The standard remedy is compaction — moving allocated objects to consolidate free space — but compaction requires the ability to update all pointers, a capability that manual-memory languages lack without explicit support.