Join 4,000+ others and never miss out on new tips, tutorials, and more.
pecl install openswoole-22.0.0 | composer require openswoole/core:22.1.2
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 is also 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 OpenSwoole:
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