hn.today

Memory management in 40 major C projects, a survey

theconsensus.dev8 points1 comments
Screenshot of Memory management in 40 major C projects, a survey

A survey of 40 major C projects examines how they allocate and release memory, challenging the idea that C code relies exclusively on programmers pairing malloc with free. Only eight projects use malloc/free as their sole allocation strategy, while two avoid those functions entirely. Fifteen use regions somewhere in their code: regions let a program free many allocations at once, rather than freeing each object individually, and seven projects use them as their main strategy. Five primarily use garbage collection, and three primarily use reference counting. The survey covers projects tracked among more than 400 software infrastructure projects, excluding test code, third-party code, and examples.

The findings also complicate assumptions about projects known for careful engineering. SQLite handles all its memory manually, while cURL and Redis are mostly manual, with reference counting used for some objects. Linux and QEMU have recently adopted compiler-extension-based scope cleanup, which automatically releases resources when they leave scope. The survey classifies each project’s main strategy by counting allocation call sites, a useful but limited measure that does not account for allocation sizes or how much memory is handled within regions. seL4 is a special case because it has no heap at all. Overall, the results show that major C projects use a broad mix of memory-management techniques, often combining approaches rather than relying on one system.

Read on theconsensus.dev1 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Aristotle Expands into Rust

Aristotle Expands into Rust

Aristotle has expanded its formal verification platform to Rust, allowing developers to prove code meets specifications and contains no undefined behavior, including in unsafe blocks. It can also verify that Rust rewrites behave like their original C code, targeting critical software such as smart contracts and infrastructure. (harmonic.fun)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.