Mimalloc

From Alpine Linux

Mimalloc is a drop-in replacement for malloc and can be used in other programs without code changes, for example, on dynamically linked ELF-based systems.

Installation

To use mimalloc, ensure mimalloc package is installed on your Alpine Linux system:

# apk add mimalloc

Configuration

To minimize risks while leveraging mimalloc, consider per-application preloading.

Using mimalloc per-application

Preload libmimalloc.so only for specific applications by issuing the following command:

LD_PRELOAD=/usr/lib/libmimalloc.so my-application

If preloading fails or causes issues, you can unset it temporarily:

unset LD_PRELOAD

To use mimalloc for firefox:

LD_PRELOAD=/usr/lib/libmimalloc.so firefox

Using mimalloc systemwide

Note: Using mimalloc systemwide is not recommeneded as this is not guranteed to work for all applications. Test your critical applications using per-application before deploying it systemwide

To preload libmimalloc.so systemwide, set the LD_PRELOAD environment variable globally by adding the line export LD_PRELOAD=/usr/lib/libmimalloc.so to the global shell configuration file /etc/profile as follows:

Contents of /etc/profile

export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # Set LD_PRELOAD to use mimalloc globally export LD_PRELOAD=/usr/lib/libmimalloc.so export PAGER=less umask 022 ...

See also

Official website