3

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

Marek Lipka
  • 50,622
  • 7
  • 87
  • 91
Vivek
  • 33
  • 1
  • 3

1 Answers1

21

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
Marek Lipka
  • 50,622
  • 7
  • 87
  • 91
  • to install jemalloc , used the command 1-sudo apt-get install libjemalloc-dev – Vivek Aug 07 '19 at 10:49
  • to install jemalloc , used the command 1-sudo apt-get install libjemalloc-dev to reinstall ruby with rvm I used the following command RUBY_CONFIGURE_OPTS=--with-jemalloc rvm reinstall 2.6.3 but still jemalloc library ,I am not getting with the suggested command. – Vivek Aug 07 '19 at 10:55
  • 1
    I don't know, but it should be quite easy to install Ruby with jemalloc using `rvm`, it goes simply like this: `rvm install 2.6.3 -C --with-jemalloc` (or `rvm reinstall 2.6.3 -C --with-jemalloc` if you're reinstalling it). – Marek Lipka Aug 07 '19 at 11:02
  • I used your command and now I am able to see the jemalloc library . Many thanks!! – Vivek Aug 07 '19 at 11:17