Skip to content
0:00 / 0:00

#mesh#malloc#memoryfragmentation

"Compacting the Uncompactable" by Bobby Powers

Strange Loop Conference

88K subscribers • 114 videos on Hallway • Conference channel

YouTube
  • Recommended by 3 people: 3 on Hacker News.
  • A classic. People kept recommending it from 2020 to 2025.
  • Presented by Bobby Powers

Advanced. Deep dive for people who know the field.

29K views7 years ago3 recommendations

Systems programmingProgramming languagesMemory managementPerformance and optimizationC

Bobby Powers introduces Mesh, a drop-in malloc replacement that eliminates memory fragmentation in C and C++ programs through compaction.

Programs written in C/C++, can suffer from serious memory fragmentation, leading to low utilization of memory, degraded performance, and application failure due to memory exhaustion. This problem extends to languages like Ruby and Python, where the standard interpreters for these languages are themselves C programs. This talk introduces Mesh, a plug-in replacement for malloc that, for the first time, eliminates fragmentation in unmodified C/C++ applications through compaction. A key challenge is that, unlike in garbage-collected environments, the addresses of allocated objects in C and C++ are directly exposed to programmers, and applications may do things like stash addresses in integers or store flags in the low bits of aligned addresses. This hostile environment makes it impossible to safely relocate objects, as the runtime cannot precisely locate and update pointers. Mesh combines novel randomized algorithms with widely-supported virtual memory operations to provably reduce fragmentation, breaking long-established worst-case bounds on memory efficiency with high probability. Mesh generally matches the runtime performance of state-of-the art memory allocators while reducing memory consumption and eliminating pathological cases; in particular, Mesh reduces the memory of consumption of Firefox by 16% and Redis by 39%. There are efforts underway to incorporate Mesh's approach to eliminate fragmentation into existing allocators, like jemalloc. Bobby Powers University of Massachusetts Amherst @lilbobbypowers Bobby is a PhD candidate in the PLASMA Lab at UMass Amherst, and a software engineer at Stripe. His interests span systems and programming languages, with a focus on making existing software more efficient, more secure, and usable in new contexts.

Why it's here

3 people recommend this

What people say. Recommended for its innovative approach to solving memory fragmentation in non-garbage-collected languages.

remexreon Hacker News • Recommends

On “How the Python object system works”

There's an interesting talk 0 from Bobby Powers on how to make a malloc() and free() that perform compaction, to be able to release memory back to the operating system more frequently (and improve cache hit rates, etc.). But this isn't standard at all yet. 1: link to this video

rtfeldmanon Hacker News • Recommends

On “Reference count, don't garbage collect”

There was a great talk at Strange Loop about a drop-in malloc replacement which compacts. Apparently it actually led to memory usage improvements in industrial projects like Redis: link to this video

superjanon Hacker News • Recommends

On “Using black magic to make a fast circular buffer (2017)”

There’s a great paper from the group of Emery Berger, where they merge memory pages that become sparse. A kind of garbage collection for C and C++ languages. There’s also a good presentation about it on youtube. link The presentation: link to this video

ssokolowon Hacker News • Mentions

On “Rust Is Hard, Or: The Misery of Mainstream Programming”

> but malloc/free based systems also have a relatively high memory overhead due to fragmentation In case you haven't seen it, there's been some interesting progress on that front: link to this video