I also wrote it on the blog, so I'll post it here too.
There is a library called Jemalloc, which is a memory allocator that reduces locks in a multi-threading environment and
reduces memory fragmentation.
In php 8.5, the bug related to specifying an external memory allocator was fixed, so we can now use jemalloc.
(Thanks to the Psalm team at Biomed)
I learned about it while reading the psalm (php static analyzer) blog, and it says that psalm performance has improved by 30%.
According to the techempower benchmark, Ruby also uses jemalloc to reduce RAM usage and improve performance.
https://storck.io/posts/psa-switch-ruby-docker-to-jemalloc-now/
In Ruby, fragmentation is definitely reduced, reducing RAM usage.
How to specify in Docker
# Use Jemalloc for optimize
RUN apt install libjemalloc2 # Installation based on Ubuntu
ENV LD_PRELOAD= libjemalloc.so.2 # Setting in PHP