rubyubuntujemalloc

How to check ruby-2.6.3 is using jemalloc ? I installed ruby-2.6.3 as $ rvm install 2.6.3 -C --with-jemalloc


This command should show -ljemalloc but it is not. I could see it with ruby-2.4.3 and ruby-2.5.x but not with ruby-2.6.x

$ ruby -r rbconfig -e "puts RbConfig::CONFIG['LIBS']"
-lm                                                                                                                                    
$ cat /etc/environment


PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1

I am using ubuntu 18 LTS and with other ruby version , I am getting the jemalloc file library as mention above


Solution

  • In ruby 2.6.x, you have to check MAINLIBS, like this:

    $ irb -rrbconfig
    irb(main):004:0> RbConfig::CONFIG['MAINLIBS']
    => "-lz -lpthread -lrt -lrt -ljemalloc -lgmp -ldl -lcrypt -lm "
    

    or, of course, with your one-liner:

    $ ruby -r rbconfig -e "puts RbConfig::CONFIG['MAINLIBS']"
    -lz -lpthread -lrt -lrt -ljemalloc -lgmp -ldl -lcrypt -lm