The lost malloc()
A historical review of early Unix source code reveals how memory allocation, explicit resource maps, linear allocators, and early garbage collection evolved from V4 to V8.
read it The deep dive into historical Unix source code and early memory allocation strategies offers genuine architectural insights for systems programmers.
summary
Exploring early Unix source code from version 4 through 8, the author traces the evolution of memory management before standard C library conventions were established. Early versions used simple linear allocators and explicit resource maps like coremap and swapmap that passed sizes to deallocation functions. Over time, Unix flirted with garbage collection and preprocessor macros resembling C++'s new before eventually settling on traditional malloc and free interfaces. The post highlights how hardware constraints and simple program lifetimes shaped these early systems engineering decisions.
key points
- Early Unix editions like V4 utilized a simple linear allocator running on sbrk that lacked a free mechanism because programs had short, self-contained lifespans.
- Dennis Ritchie's early malloc and mfree interfaces required explicit resource maps and passed the allocation size directly to mfree.
- Versions 7 and 8 experimented with preprocessor macros mimicking C++-style new and even introduced garbage collection via galloc before adopting standard malloc/free.
who should read it
Systems programmers and computer science historians interested in the roots of C and Unix memory management.
discussion warm
consensus
Commenters thoroughly enjoyed the historical deep dive, sparking side debates on whether passing allocation sizes to free is a historical blunder or a feature.
pushback
Some commenters pushed back on the author's praise of explicit sizes in free and linear allocators, noting they introduce fragmentation and unnecessary bookkeeping.
The author did not really find from where SIMULA 67 had taken "new".
In November 1965, C.A.R. Hoare published an extremely influential paper: "Record Handling". This was a proposed extension for the successor of ALGOL 60.
Almost all of the features that were added in SIMULA 67 over its predecessor, the SIMULA language, come directly from the paper of Hoare, with two big exceptions: class inheritance and the "virtual" procedures, which were invented by the SIMULA 67 creators (Kristen Nygaard & Ole-Johan Dahl) and which are essential for object-oriented programming.
The SIMULA 67 keywords …
It traces the actual historical lineage of the new keyword and record handling back to C.A.R. Hoare's 1965 paper rather than Simula 67.
Generated by an LLM from the article and thread. Check the sources before relying on it.