---
title: "Memory management in 40 major C projects, a survey"
authors:
  - "Phil Eaton"
year: 2026
venue: "The Consensus (theconsensus.dev), 8 Nov 2026"
arxiv: null
doi: null
source: "https://theconsensus.dev/p/2026/11/08/c-memory-management-survey.html"
version_reviewed: "web 2026-11-08"
topics:
  - "memory-management"
  - "region-based-memory"
  - "arena-allocation"
  - "reference-counting"
  - "garbage-collection"
  - "scope-cleanup"
  - "c"
seed_rank: 2773
seed_batch: "craft-2026-12-01"
reviewed: "2026-12-01"
pool: "systems"
relevance_score: 7
lineage: memory-allocators
cites:
  - title: "Memory management in 40 major C projects, a survey"
    url: "https://theconsensus.dev/p/2026/11/08/c-memory-management-survey.html"
    year: 2026
    arxiv: null
    doi: null
see: []
---

# Memory management in 40 major C projects, a survey

## One-sentence takeaway

A call-site census of how 40 major C codebases allocate (excluding tests, vendored code and examples). Only 8 allocate solely with malloc/free (brotli, FreeRTOS, HAProxy, libdeflate, lz4, SQLite, xz-utils, zlib), 16 use regions somewhere, 7 are primarily region-allocated (Citus 99%, pgvector and TimescaleDB 100%, httpd 97%, nginx 92%, Postgres 77%, ggml 65%), 5 are primarily garbage-collected and 3 primarily reference-counted. Linux and QEMU are adopting compiler-extension scope cleanup (`__free(kfree)`, `g_autofree`). A per-project table names the actual allocator entry points.

## Why it matters here

Anoptic is a C23 engine organised around arenas and regions, and this is the closest thing to field evidence for that choice in large, long-lived C systems. The region-heavy group is the request- or query-scoped servers (nginx pools, APR pools, Postgres `MemoryContext`s and the extensions built on them), which is the same shape as a frame or tick-scoped game loop. It also shows that famously careful code (SQLite) can stay 100% manual. The per-project API table works as a reading list of production region APIs to compare against Anoptic's arena interface: `apr_pool_create`/`apr_pool_clear`, `ngx_create_pool`/`ngx_destroy_pool`, `palloc`/`MemoryContextReset`, `zend_arena_alloc`, `_PyArena_New`, Neovim's `arena_memdupz`, zstd's `ZSTD_cwksp`. The scope-cleanup trend also bears on whether Anoptic should lean on `__attribute__((cleanup))`. The Anoptic reading is mine.

## Key ideas

- **Metric.** The share of allocation *call sites* per strategy, not bytes or allocation counts. seL4 is the outlier with no heap at all.
- **Mostly-manual majority.** 16 projects are primarily malloc with a minority strategy, for example git (96% manual, 3% `mem_pool`), Linux (82% manual, 18% `devm_` managed), Xen (58/42), zstd (81/19 workspace), tree-sitter (74% manual, 26% refcounted).
- **Region-first systems.** These are database and web-server cores and their extensions, plus ggml's tensor context. Freeing a region frees everything in it, sometimes nested, sometimes with individual frees still allowed.
- **GC and refcount camps.** The GC camp is language runtimes (Emacs, Julia, Lua 99%, OCaml, Ruby). Refcounting dominates in CPython (82%), Perl and PHP (with PHP also using arenas and a cycle collector).
- **Scope cleanup.** Linux `__free(kfree)` and QEMU `g_autofree` show RAII-like cleanup arriving in mainstream C through compiler extensions.

## Caveats

Counting call sites is a crude proxy. It ignores allocation size, frequency, lifetime and hot-path weight, and the classification of wrapper functions is the author's. There are no games or engines in the sample, and the 40 projects come from The Consensus's tracked set, not a principled population. This is a journalism-style survey with no methodology appendix or reproducible scripts in the article. I read the full public article.

## Links

- Article (HTML): https://theconsensus.dev/p/2026/11/08/c-memory-management-survey.html
