Faster Mac dev tools with custom allocators
eisel.me
eisel.me
1. Degenerate cases with new allocator designs, e.g. being better for some workloads and not others
2. Bug-for-bug compatibility - applications which break due to dependencies on undocumented behavior or the old allocator memory structures.
3. Boundary conflicts - systems where an allocator change would mean allocation and free are hitting different implementations across module boundaries, as one module allocates memory for another to consume. Some systems and programming languages are more vulnerable to this sort of issue.
In any case, Apple and others have invested hugely in LLVM AddressSanitizer, so the Electric Fence-like malloc debugging features are considered more of a last resort these days.
[1]: http://jemalloc.net/jemalloc.3.html
[2]: https://chromium.googlesource.com/external/gperftools/+/gper...
GWP ASAN from TCMalloc might be the better direction for runtime support for memory corruption from malloc as it gives a lot of ASAN-like protection with an electric fence-like performance profile (& can be turned on/off at runtime).
The reason was due to memory fragmentation over time and jemalloc reduced this to a level that we could live with.
We’ve tried other allocators over the years but still jemalloc, or our version of to be precise, is the winner in memory usage and fragmentation.
Edit: performance wise, gains can be had by doing your own memory pools on a per-thread basis and making use of stack objects rather than heap objects. Larger allocations for your own object pools and managing those reduces the calls to malloc also helps reduce memory fragmentation and your vmsize diverging from your rss.
It appears to benchmark better than even jemalloc and others.