Doug Lea’s page on his memory allocator is still up, still public domain, and still carrying a line at the top that most software documentation would rather bury: “This article is now out of date, and doesn’t reflect details of current version of malloc.” The page is at gee.cs.oswego.edu. Lea started writing the allocator in 1987, and people have called it dlmalloc ever since, mostly because he never gave it a name.

The reason to read it now is not nostalgia. It is that the essay is a working model of how infrastructure software actually gets built, and the constraints it names are the constraints that now shape AI systems. Lea wrote the first version after C++ programs that leaned on dynamic allocation ran “much more slowly and/or with much more total memory consumption” than he expected, a problem he traced to the allocators in then-current SunOS and BSD. He tried special-purpose allocators first, overloading operator new per class, then concluded that was the wrong strategy for general-purpose library work. From 1986 to 1991 he was primary author of libg++.

That origin story is the AI story. The model is not usually the slow part. The memory is.

The trade-off list is the interesting part

Lea’s goals section reads like a checklist that every inference stack is quietly failing somewhere. Maximize compatibility. Maximize portability. Minimize space. Minimize time. Maximize tunability. Maximize locality. Maximize error detection. Minimize anomalies. He is explicit that these fight each other. Worst-case alignment requirements increase wastage by forcing the allocator to skip bytes. Debug modes that catch errors “seriously impact time efficiency by adding levels of indirection and increasing numbers of branches.” Heuristics that help small programs hurt large ones.

Two specifics on that page are worth pinning down because they are the kind of thing that gets lost in a generation of abstraction layers. The smallest allocatable chunk is 16 bytes on 32-bit pointers and 24 bytes on 64-bit pointers, because each available chunk has to carry both size information and bin links. And the allocator keeps 128 fixed-width bins, roughly logarithmically spaced, with sizes under 512 bytes spaced 8 bytes apart to make 8-byte alignment easy to enforce. Searches run smallest-first, best-fit. Since the 1995 versions, chunks are sorted by size within bins, ties broken oldest-first, because the minor time cost beat the observed bad cases.

Lea also cites the Wilson, Johnstone, Neely and Boles survey from the 1995 International Workshop on Memory Management, which argued that minimizing wastage has to be the primary goal in any allocator. The survey put a dollar figure on it: poor allocation schemes cost people “perhaps even billions of dollars in memory chips.” That was 1995 money.

Every token an inference server holds in a KV cache is a chunk someone has to allocate, free, and hope not to fragment.

What this means for AI builders

The AI industry has spent three years buying compute and almost no time thinking about the layer between the model and the silicon. That layer is where dlmalloc lives. Every token an inference server holds in a KV cache is a chunk someone has to allocate, free, and hope not to fragment. Every batch scheduler that pads sequences to a fixed length is making the same trade Lea describes: waste space to save time, or waste time to save space. Every profiler that shows a training job stalling on host memory is running into the boundary-tag and binning decisions made in 1987.

The current generation of AI systems software has partly rediscovered this. Paged attention schemes, custom caching allocators in the major frameworks, and the move toward unified memory on accelerators are all attempts to answer Lea’s question: how do you keep fragmentation from eating your capacity? The answer is rarely a new algorithm. It is usually a better fit between the allocator and the workload, which is exactly what Lea says drove his own evolution. “Changes in target workloads,” he writes, were one of the driving forces. The memory characteristics of windowing systems dominated his era. Transformer inference dominates this one.

There is a policy angle too, and it is not subtle. Memory is the component AI supply chains cannot substitute around. Lea’s line about wastage measured “monetarily” as billions in memory chips is the same arithmetic that shows up in export-control debates over HBM and advanced packaging. If a meaningful share of accelerator capacity is lost to allocator inefficiency, then the effective compute a country or a lab controls is smaller than the nameplate number. Nobody puts that in a press release.

The part that should make engineers uncomfortable

Lea’s page is honest in a way that current AI infrastructure marketing is not. He admits the minimum chunk sizes are “larger than most people would like to see” and can cause significant wastage in applications allocating many tiny linked-list nodes. He admits that dropping trailer fields on in-use chunks saved overhead but “weakens error detection a bit.” He admits that until 1993 he allowed realloc on already-freed memory for compatibility, and that “no one at all complained” when the feature was dropped.

That is what a mature infrastructure discipline sounds like. It names the cost of every choice. It does not claim the allocator is fast and lean and safe and portable all at once. The AI stack would benefit from the same habit, especially as inference costs become the number that decides which companies survive. The models get the papers. The allocators get the bill.

The outstanding question is whether the AI systems community will treat memory management as a first-class research area or keep treating it as a wrapper around a vendor runtime. Lea’s page has been answering that question, in public, for nearly four decades. It is still the best place to start.