benmandrew.com explains glibc malloc internals

benmandrew.com13 min read

This article explores how memory allocation functions in C by building a series of toy allocators from scratch using system calls like sbrk and mmap. The author demonstrates how glibc optimizes memory management through chunk headers, free lists, heap trimming, and thread caches to avoid the high costs of frequent kernel system calls. Open article →