A deep investigation into a memory leak in Meilisearch that persisted for 1.5 years. The root cause was twofold: a bumpalo bump allocator misuse where std::Vec objects stored inside bumpalo::Vec never had their drop glue run, and a more significant issue where LMDB (a C library) and Meilisearch used different allocators (system allocator vs mimalloc v2), preventing memory page reuse. Switching to mimalloc v3 with its override feature to unify allocations across both Rust and C code resolved the leak, yielding lower RSS memory usage and performance improvements of around 13% in some benchmarks. The investigation used jemalloc's profiling tools and LLM-assisted heap analysis to identify the issues.

10m read timeFrom meilisearch.com
Post cover image
Table of contents
Jemalloc to the rescueThe trap of bumpaloThe downsides of using non-Rust dependenciesUsing mimalloc everywhere

Sort: