The Lost malloc(): Unix's Regional Memory Approach
The author examined early Unix source code to understand how the system managed memory allocation. The simplest approach was a linear allocator that advanced a pointer through a heap and extended it when needed, with no deallocation—a practical design for programs that ran to completion and exited.
More notably, early Unix kernels used a malloc/mfree interface distinct from modern C. Both functions took an explicit memory “map” parameter (coremap or swapmap) and required callers to specify allocation size. This partitioned memory by resource type, theoretically reducing heap corruption severity and allowing limits on third-party code consumption. The designers likely adopted this for hardware pragmatism: main memory and disk swap required different block sizes and management strategies.
Subsequent Unix versions introduced list-based allocation with block coalescing, followed by macros to eliminate manual size calculations. The independent use of similar patterns across different tools suggests these weren’t grand designs but practical solutions to real constraints.
Read the full article
Continue reading at Hacker News →This is an AI-generated summary. Read the original for the full story.