Doug Lea's Malloc

https://gee.cs.oswego.edu/dl/html/malloc.html

Comments

senderistaNov 29, 2026, 4:38 AM
It was a good single-threaded allocator back in the day but in the multicore era the design is now thoroughly obsolete. I suggest reading e.g. the jemalloc[1] and mimalloc[2] papers if you want to understand how modern allocators are implemented.

[1] https://people.freebsd.org/~jasone/jemalloc/bsdcan2006/jemal...

[2] https://www.microsoft.com/en-us/research/wp-content/uploads/...

HexDecOctBinNov 29, 2026, 5:36 AM
Considering that global allocators are usually an anti-pattern and that most applications should have component-specific allocators, dlmalloc isn't all that bad when used through its mspace API. Of course, if one doesn't actually need a general allocator, they should simply use an arena allocator.
ConscatNov 29, 2026, 6:47 AM
Musl still supports single threaded slab allocations. In Musl, the difference comes down to one lock, some atomics, and a #define. My library extracts out its algorithm and let's you use scoped single and multi threaded Musl allocators freely mixed with each other.
jartNov 29, 2026, 6:58 AM
Cosmopolitan uses dlmalloc and just wraps it with an rseq allocator for multicore performance. See also https://jart.dev/rseq/
brcmthrowawayNov 29, 2026, 6:13 AM
Has anyone tried jev as an allocator?
benatkinNov 29, 2026, 6:43 AM
Brilliant. "End-to-end response time is 70ms-500ms for TypeSafe." https://typesafe.ai/blog/introducing-system-one-models-and-j... That could work for some use cases.
pcwaltonNov 29, 2026, 7:02 AM
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.
ncrucesNov 29, 2026, 7:43 AM
Still used quite a bit on Wasm/WASI (mostly single threaded).

I recently switched to using TLSF for that: https://github.com/ncruces/wasm2go/blob/main/libc-gen/c/mall...

asveikauNov 29, 2026, 4:29 AM
In the mid 2000s I was a student in upstate NY and I very briefly met Doug Lea. (I'm 100% sure he doesn't remember me at all.) He was a very warm, approachable, down to earth guy. The computer labs at Oswego had a bunch of giant Sun Microsystems logos on all the gear, I guess because they were funding him.
acyclicNov 26, 2026, 9:01 AM
The only algorithm to be named after someone's full name, first and last name
tripdoutNov 29, 2026, 5:10 AM
I believe this was the original malloc used in Android's bionic libc.
egberts1Nov 29, 2026, 5:42 AM
False.

Android up to v4.1 bionic is based on Doug Lea's dlmalloc v2.8.3

Android v4.2 upgraded to dlmalloc v2.8.6

Android v5.0 transitioned to jemalloc.

Modern Android is based on jemalloc or Scudo, based on build configuration.

Android never used original dlmalloc.

ConscatNov 29, 2026, 6:50 AM
Am I confused or did you agree with your parent comment that dlmalloc was the original algorithm used by Android?