ext-swooleis supported until v4.7.1, use
ext-openswoole>= v4.7.1. Latest version:
pecl install openswoole-4.9.1
It is not recommended to use jemalloc, it may reduce the stability of your program but it is supported. It is recommended to use the standard malloc and the official PHP emalloc (default).
jemalloc is a more efficient memory pool technology than glibc
malloc. It is widely used by Facebook, and
jemalloc is used as the default memory manager in FreeBSD and FireFox projects. Using
jemalloc can help improve the memory management performance of your program and may reduce memory fragmentation.
Official GitHub: https://github.com/jemalloc/jemalloc
Follow the download instructions and compile then install:
cd jemalloc ./configure --with-jemalloc-prefix=je_ make -j 4
jemalloc, you can configure it to work with Swoole:
phpize ./configure --with-jemalloc-dir=/path/to/jemalloc make make install
You can also use different memory pool implementations by using
LD_PRELOAD, for example, we can also use Google's
LD_PRELOAD="/usr/lib/libjemalloc.so" php server.php LD_PRELOAD="/usr/lib/libtcmalloc.so" php server.php