Ruby 2.6.5 with jemalloc
Asked Answered
S

3

4

I've built and installed rub 2.6.5 from source with jemalloc. However when I check to see if its there I'm not seeing an entry. Is there something else I should have been doing?

ubuntu:~$ uname -a
Linux ip-10-0-3-198 4.15.0-1032-aws #34-Ubuntu SMP Thu Jan 17 15:18:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
ubuntu:~$ ./configure --enable-shared --with-jemalloc
ubuntu:~$ make
ubuntu:~$ make install

Which results in:

ubuntu:~$ ruby -r rbconfig -e "puts RbConfig::CONFIG['LIBS']"
-lm 

Tracking memory usage once deployed I'm also not seeing a drop compared to similarly configured servers without jemalloc in place.

I'm not sure what I need to be doing in order to get jemalloc working.

Thanks!

Soria answered 3/12, 2019 at 9:54 Comment(0)
I
7

Try:

puts RbConfig::CONFIG['MAINLIBS']

And check for -ljemalloc in the output.

This behavior has changed recently (in 2.6.x, to be precise).

Implicit answered 3/12, 2019 at 10:14 Comment(2)
Thanks! I do indeed see jemalloc in the list: "$ ruby -r rbconfig -e "puts RbConfig::CONFIG['MAINLIBS']" -lz -lpthread -lrt -lrt -ljemalloc -lgmp -ldl -lcrypt -lm"Soria
Thanks. Sadly not really seeing an improvement in memory usage though. Back to the investigation.Soria
F
9

For some reason, the accepted answer does not work for me (Heroku), but this:

MALLOC_CONF=stats_print:true ruby -e "exit"

has done the trick.

If you have some stats ouput, means it's working.

source: https://github.com/gaffneyc/heroku-buildpack-jemalloc/issues/5#issuecomment-499932026

Forevermore answered 27/3, 2020 at 9:56 Comment(0)
I
7

Try:

puts RbConfig::CONFIG['MAINLIBS']

And check for -ljemalloc in the output.

This behavior has changed recently (in 2.6.x, to be precise).

Implicit answered 3/12, 2019 at 10:14 Comment(2)
Thanks! I do indeed see jemalloc in the list: "$ ruby -r rbconfig -e "puts RbConfig::CONFIG['MAINLIBS']" -lz -lpthread -lrt -lrt -ljemalloc -lgmp -ldl -lcrypt -lm"Soria
Thanks. Sadly not really seeing an improvement in memory usage though. Back to the investigation.Soria
R
0

For ones using LD_PRELOAD and not building ruby directly, a more complete answer would be:

RbConfig::CONFIG['MAINLIBS'].include?("jemalloc") || ENV['LD_PRELOAD'].include?("jemalloc")

Of course this is not enough to tell if jemalloc really is working, as for the accepted answer!

Reprobative answered 13/4, 2021 at 16:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.