logoalt Hacker News

Doug Lea's Malloc

35 points • by grep_it • last Thursday at 4:07 AM • 16 comments • view on HN

Comments

senderista • today at 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/...

➕ show 3 replies
pcwalton • today at 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.

sph • today at 9:05 AM

Use case: it’s a fantastic memory allocator for your hobby OS. After you have implemented a page allocator, copy dlmalloc.c, adapt it slightly and you’re good to go.

Also it’s public domain.

asveikau • today at 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.

ncruces • today at 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...

acyclic • last Thursday at 9:01 AM

The only algorithm to be named after someone's full name, first and last name

➕ show 1 reply
tripdout • today at 5:10 AM

I believe this was the original malloc used in Android's bionic libc.

➕ show 1 reply
grotz • today at 8:34 AM

(0x1) or (1x1) read-write

Those are lines from the basic algorithm.