4 ms·
Understanding glibc malloc
- ignoramous 12y agoDoug Lea's dlmalloc implementation is the basis for GCC's ptmalloc, IIRC. His writeup on the topic is a wonderful read; and for the code itself, it is beautifully organised and well commented. http://g.oswego.edu/dl/html/malloc.html http://g.oswego.edu/dl/html/malloc.html
- deleted 12y ago[deleted]
- rayiner 12y agojemalloc is also pretty well-documented, though it's relatively big for a malloc implementation. BSDcan paper: http://people.freebsd.org/~jasone/jemalloc/bsdcan2006/jemalloc.pdf; http://people.freebsd.org/~jasone/jemalloc/bsdcan2006/jemall... Facebook Engineering post: https://www.facebook.com/notes/facebook-engineering/scalable-memory-allocation-using-jemalloc/480222803919 https://www.facebook.com/notes/facebook-engineering/scalable.... The NetBSD version, though probably not the most up to date, is the easiest to understand, being in a single file: http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdlib/jemalloc.c?rev=1.37&content-type=text/x-cvsweb-markup&only_with_tag=MAIN http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdlib/jema....
- peri 12y agoThe NetBSD is also a great starting point for people who want to port to weird architectures. It's simple and a little old fashioned, but it's in the sweet spot for most bootstrappable C compilers for memory-constrained devices. This or dmalloc are usually the easiest to get up and running on a device where you can't or don't want to trust the system libraries.