What is malloc doing, anyway?
Summary
The article explains what malloc actually does behind the scenes, using strace measurements and code examples to show how allocations are satisfied with a small number of system calls and then served from the process heap. It covers the address space layout, the concept of a bump allocator, and how malloc uses headers, free lists, splitting, and coalescing to manage memory. It also discusses demand paging, trimming memory back to the kernel, and the trade-offs between sbrk-based heaps and mmap-backed blocks, culminating in a performance comparison with glibc malloc.