Doug Lea's Malloc
Doug Lea outlines the design goals, boundary tag algorithms, and performance trade-offs of his widely adopted public-domain memory allocator, dlmalloc.
summary is enough While historically foundational for understanding memory allocators, the text is dated and modern systems have largely replaced dlmalloc with thread-aware alternatives.
summary
Written by Doug Lea, this retrospective details the architecture of dlmalloc, a public-domain memory allocator created in 1987. It explores core constraints like balancing space efficiency and speed, alongside implementation mechanisms like boundary tags and sized bins. Although foundational, the design is largely obsolete for modern multicore hardware and threaded workloads.
key points
- Dlmalloc uses boundary tags for chunk coalescing and 128 logarithmically spaced bins for best-fit memory retrieval.
- General-purpose allocators must constantly trade off execution time, space fragmentation, portability, and error detection capabilities.
- Commenters note that inline metadata and a single-threaded design make dlmalloc poorly suited for modern security and multicore environments.
who should read it
Systems programmers and computer science students studying memory management implementation.
discussion mixed
consensus
Commenters agree that dlmalloc is obsolete for modern multicore software, having been largely superseded by thread-aware allocators like jemalloc and mimalloc.
pushback
A minority point out that global heaps are architectural anti-patterns anyway, and component-specific arena allocators are often superior.
Besides the lack of thread-local allocation buffers that other comments have mentioned, the other problem with dlmalloc is that the metadata is stored inline, right next to the chunks. This is bad for security as it makes it much easier to weaponize out-of-bounds writes.
It explains how inline metadata introduces security vulnerabilities via out-of-bounds writes, a major practical concern absent from the original text.
Generated by an LLM from the article and thread. Check the sources before relying on it.