Oriel — AI & technology worth noticing, every day.

The lost malloc()

Web page · https://napcakes.nekoweb.org/posts/malloc

First seen by Oriel on .

AI summary

This historical code archaeology traces Unix memory allocation from V4 linear allocators and explicit resource maps to familiar malloc()/free() interfaces and type-aware allocation macros.

  • V4's compiler alloc() aligned sizes, extended the heap with sbrk(), and never freed memory because allocations lasted for the program's lifetime.
  • Dennis' malloc.c accepted an explicit coremap or swapmap, enabling first-fit allocation, neighboring-block coalescing, and separate main-memory and swap-resource management.
  • V6 code demonstrated arena rollback by resetting area, while V7 introduced ALLOC(x) and V8 included zero-initializing tryalloc and several new(type) macros.
  • The post connects C allocation practices with Simula and Cfront, while noting that historical designs were heavily shaped by limited memory and absent virtual memory.
  • Most Unix programs still performed allocation and size calculations directly at call sites, despite the availability of macros intended to reduce those errors.

#unix #memory allocation #c #simula

Generated by gpt-5.6-sol. Check the original for details.

Metric trends

Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained

Points

Score reported by the source.

  • Hacker News: 158, latest observation ; +154 over observed period since
  • Lobsters: 34, latest observation ; +33 over observed period since

Comments

Comment count reported by the source.

  • Hacker News: 75, latest observation ; +74 over observed period since
  • Lobsters: 5, latest observation ; +5 over observed period since

Aliases

SourceExternal IDURL
Hacker News50362466https://napcakes.nekoweb.org/posts/malloc/ Read discussion
Lobstersihqhiahttps://napcakes.nekoweb.org/posts/malloc/ Read discussion