Hacker News new | past | comments | ask | show | jobs | submit login
Understanding glibc malloc (sploitfun.wordpress.com)
93 points by ingve on July 2, 2016 | hide | past | favorite | 5 comments



Old discussion: https://news.ycombinator.com/item?id=9327526

And he forgot ptmalloc3, the improved version of the glibc malloc.


Who wrote ptmalloc3 – the original writer of ptmalloc2, or is it an independent creator who simply decided to call their fork “ptmalloc3”? In what way is it better? Why haven’t GNU libC converted to ptmalloc3?


Ad #1: yes, wolfram gloger.

Ad #2: ptmalloc3 biggest advantage over dlmalloc 2.8.3 is for multiple threads, while trying to avoid lockcontention as much as possible. But it also has e.g. a better API to support slabs and array or struct elements via independent_comalloc(), which speeds up my compiled code by 20%. You can alloc your elements in once and still individually free them.

See the malloc-2.8.3.h header: https://code.qt.io/cgit/qt/qt.git/tree/src/3rdparty/ptmalloc...

Ad #3: memory usage. ptmalloc2 has the least overhead. In my case with lots of arrays which can be independent_comalloc'ed this is not observable.


ptmalloc[0] is developed by Wolfram Gloger and is a modified version of Doug Lea's malloc (aka dlmalloc [1]).

0. http://www.malloc.de/en/

1. http://gee.cs.oswego.edu/pub/misc/malloc.c


Referring to the "Linux allocator" is confusing, since the Linux kernel also has allocators. Saying he "GNU/Linux allocator" or the "glibc allocator" would be more correct and respectful.




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

Search: