BlogsMetaScalable Memory Allocation

Scalable Memory Allocation

Scalable Memory Allocation

2
posts
2011–2026

Meta's approach to memory allocation has evolved to address the challenges of high-throughput, low-fragmentation, and robust heap profiling in large-scale server applications. This includes the adoption and optimization of jemalloc, a memory allocator that provides fast allocation/deallocation, consistent RAM usage through low fragmentation, and critical heap profiling capabilities. Innovations have focused on improving thread caching, increasing mutex granularity, optimizing dirty page purging, and a renewed commitment to modernizing the codebase, reducing technical debt, improving the huge-page allocator, enhancing memory efficiency, and optimizing for AArch64 performance.

2026

Investing in Infrastructure: Meta’s Renewed Commitment to jemalloc

3/2/2026

Meta is renewing its commitment to jemalloc, aiming to reduce maintenance needs, modernize the codebase, and evolve the allocator to adapt to the latest hardware and workloads. Key areas of focus include technical debt reduction, refactoring, enhancing the huge-page allocator (HPA) for better transparent hugepages (THP) utilization, improving memory efficiency through packing, caching, and purging mechanisms, and ensuring good out-of-the-box performance for the AArch64 (ARM64) platform. The original jemalloc open source repository has been unarchived, and Meta is actively collaborating with the open-source community.

2011

Scalable memory allocation using jemalloc

1/3/2011

This post details the integration and optimization of jemalloc for scalable memory allocation at Facebook. It highlights the core algorithms and data structures of jemalloc, including its segregation of small objects, careful choice of size classes, tight limits on metadata overhead, minimization of the active page set, and strategies to minimize lock contention through independent arenas and thread-specific caching. Facebook-motivated innovations focused on improving speed by rewriting thread caching, increasing mutex granularity, restructuring synchronization logic to drop mutexes during system calls, rewriting dirty page purging, and developing a new, faster red-black tree implementation. It also introduced introspection capabilities through `mallctl*()` API for better heap profiling and monitoring.