musl's malloc uses a global lock, which is a serious bottleneck for multi-threaded workloads like FrankenPHP. Under sustained concurrent load, malloc contention can cause threads to stall.
FrankenPHP already supports mimalloc opt-in for static builds (MIMALLOC=1) since #666, but it's off by default.
Enabling mimalloc by default would improve performance and memory behavior, especially on Alpine/musl-based Docker images.
Additionally, mimalloc's per-thread heap stats could enable a max_memory setting (restart a thread when its heap exceeds a threshold), complementing the existing max_requests setting for more targeted leak mitigation (see #2292).
What about enabling mimalloc by default on all builds?
Relates to #481