rubylinuxjemalloc

Ruby 3.0.0 seemingly doesn't use jemalloc


I've installed jemalloc and followed all the guides, but it just doesn't look like ruby is using it:

$ apt install libjemalloc2
$ ls -la /usr/lib/x86_64-linux-gnu/libjemalloc.so.2
-rw-r--r-- 1 root root xxxxxx Feb 23  2019 /usr/lib/x86_64-linux-gnu/libjemalloc.so.2
$ LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2 irb
irb(main):001:0> puts RbConfig::CONFIG['LIBS']
-lm 
irb(main):002:0> puts RbConfig::CONFIG['MAINLIBS']
-lz -lpthread -lrt -lrt -lgmp -ldl -lcrypt -lm

Does Ruby 3.0.0 require jemalloc to be loaded some other way, is the library noted somewhere else in the config or am I doing something wrong?


Solution

  • According to this comment on the docker-library Github repo for Ruby, using LD_PRELOAD would specifically run jemalloc in such a way that Ruby would be unaware of it.

    However, running the command MALLOC_CONF=stats_print:true ruby -e "exit" will output statistics if LD_PRELOAD was exported correctly.