For years, people have been using jemalloc with ruby. There are various benchmarks and discussions. Legend had it that Jemalloc 5 doesn't work as well as Jemalloc 3.
Then, one day, hope appeared on the horizon. Someone offered a config for Jemalloc 5.
The recipe would be something like this (shown with official docker ruby image).
FROM ruby:3.1.2-bullseye