Hacker News new | ask | show | jobs
by Ocha 1001 days ago
I’ve observed same, and every time I switched to jemalloc and the issue was fixed.
1 comments

Was it difficult to switch? What were the downsides / tradeoffs? (I read about jemalloc recently but don't know enough about it to confidently pursue it, but may try it on a small app if it's straight forward).
Super easy and have not had an issue with it in over 10 years of using it. There is an example here on how to do it with docker image. https://mailsnag.com/blog/optimized-ruby-dockerfile/.
Going to try this right now! Will report back.

OOC, why isn't this part a ruby default? Isn't it always better to be more memory efficient. (I'm trying to understand what the trade offs are, if any)

EDIT: well, exactly 6 minutes later, I'm done. I followed these instructions: https://elements.heroku.com/buildpacks/gaffneyc/heroku-build...

The app seems to work like usual, I'll just have to wait and see what happens to memory use.

I will reply here in 12 hours with a screen shot showing the results (before/after memory use), whatever they may be.

Also, for reference, here's the metrics for the past 24 hours (LOTS of memory problems): https://imgur.com/a/M8IHd5z

For anyone interested, here's the result: https://imgur.com/a/c62gjKQ (the red vertical line is the point from which jemalloc was used).

It looks like memory usage did indeed go down, and critical errors fell by about 84%.

For completeness, here are the metrics a full 24 hours after the change: https://imgur.com/a/lbdzFvN
Yeah, I had the same reaction last week. It's not a Ruby default because some versions of Linux can't use it. ¯\_(ツ)_/¯
Have you compared it against newer allocators like mimalloc or the rewritten tcmalloc (not the one in gperftools)? Jemalloc is a bit long in the tooth now.