Skip to content

Default to mimalloc as the memory allocator - provide max_memory config option #2302

Description

@nicolas-grekas

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions