Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Doug Lea's Malloc (oswego.edu)
29 points by grep_it 5 hours ago | past | favorite | 12 comments
 help



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/...


Cosmopolitan uses dlmalloc and just wraps it with an rseq allocator for multicore performance. See also https://jart.dev/rseq/

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.

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.

Has anyone tried jev as an allocator?

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.

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.

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.

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

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

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.


Am I confused or did you agree with your parent comment that dlmalloc was the original algorithm used by Android?



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: