HN Hall of Fame Weekly email

Let's Write a Malloc

danluu.com Books & learning Tutorials & guides Computer science Candidate
Screenshot of danluu.com captured 2026-07-20
Page preview · captured 2026-07-20

Resurfaced independently across 4 calendar years, with breakout response in 2 of them.

submissions
5
submitters
5
observed span
2014–2023
peak thread · 29 comments
202 pts
latest 20+ return · 2023-11-26
129 pts

Submission timeline

2007–2026

One slot for every year since HN launched. Height is that year's peak points; orange marks a 100+ point or 50+ comment breakout. Select a bar to open its strongest thread.

First comments on top threads

HN comment order

I semi-recently implemented a malloc tester (am TAing an OS course). Students write their own implementation of malloc and free, and then I "intercept" their calls to brk and sbrk by using macros to re-define those symbols as my own versions of those functions. It is quite nice: I have knobs to "fuzz" the alignment of returned addresses from sbrk, as well as to inject arbitrary EAGAINs, to see if they're following the man pages. Another thing that I looked…

k4st·202-point thread·

There are so many complaints here about how simplistic this is and how it is nowhere near what a "good" malloc does. That's kind of the point. Let's implement the most brain-dead version of this code. This is code you can quickly understand and reason about. It gives you a baseline to understand all the improvements that are included in a "real" malloc. It would have been nice to include a list of the types of changes that a modern…

wscott·129-point thread·

The first top-level comment from each of the four biggest threads, in HN’s own order. Excerpts are shortened; open a comment for full context.

Breakout years
2

100+ points or 50+ comments

Total points
338

reference only — not used in Hall rules or ranking

Total comments
48

reference only — not used in Hall rules or ranking

Every submission

DateTitle as submittedByPointsComments
2014-12-05A quick tutorial on implementing C memory management functionsFirst breakout · Best threadredraga20219
2017-04-17A quick tutorial on implementing and debugging malloc, free, calloc, and reallocingve10
2017-12-04A quick tutorial on implementing and debugging malloc, free, calloc, and realloc10-640
2022-09-17Malloc Tutorial (2014)mmphosis20
2023-11-26Let's Write a MallocLatest 20+ point returnyla9212929