All original content is created in Ukrainian. Not all content has been translated yet. Some posts may only be available in Ukrainian.Learn more

What is jemalloc and how does it relate to Ruby / Ruby on Rails

Post cover: What is jemalloc and how does it relate to Ruby / Ruby on Rails
This content has been automatically translated from Ukrainian.
What is jemalloc?. jemalloc (short for Jason Evans malloc) is a high-performance memory allocator that replaces the standard malloc implemented in the standard glibc library. It is used by large projects such as Redis, Firefox, Facebook, and even Android.
Its main advantages:
  • Less memory fragmentation
  • Better multithreaded performance
  • Transparent memory usage logging (through jemalloc profiling)

Why is jemalloc important for Ruby / Rails?

Ruby uses malloc for memory management, especially when working with objects. Under heavy load (for example, multithreaded Puma or Sidekiq), the standard allocator can cause memory fragmentation and slow cleanup.
By replacing malloc with jemalloc, you can achieve:
  • Less memory consumption in long-running processes
  • More stable RSS (Resident Set Size)
  • Potentially faster GC (Garbage Collector), as jemalloc better manages object placement

When does it make sense to enable jemalloc (if you haven't done so yet)?

If you notice that your Ruby / Rails processes are "bloated" in memory after a few hours or days of operation — jemalloc can significantly help.
This is especially noticeable on:
  • Sidekiq / Resque
  • Puma / Unicorn under load
  • Services with long-running processes

This post doesn't have any additions from the author yet.

Where to find an older version of Google Chrome and download it? Using an old Mac as an example.
Apr 25, '25 23:02

Where to find an older version of Google Chrome and download it? Using an old Mac as an example.

May 9, '25 19:27

[FIXED] cannot load such file -- html/pipeline (LoadError) occurs during rails generate thredded:install

Task: Convert a Roman numeral to decimal (Ruby)
May 20, '25 12:05

Task: Convert a Roman numeral to decimal (Ruby)

Task to check the correctness of bracket placement (Ruby)
May 21, '25 10:27

Task to check the correctness of bracket placement (Ruby)

How to find the maximum subarray sum in Ruby
May 22, '25 11:01

How to find the maximum subarray sum in Ruby

Google Ads for Dummies: A Step-by-Step Guide for a Successful Start
May 28, '25 10:21

Google Ads for Dummies: A Step-by-Step Guide for a Successful Start

Jun 5, '25 01:52

[Fixed] uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger (NameError)

The preview in the network tab after the Chrome update has become very small.
Jun 5, '25 18:23

The preview in the network tab after the Chrome update has become very small.

What is the HEIC format and why simply renaming it to .jpg is a bad idea
Jun 15, '25 18:17

What is the HEIC format and why simply renaming it to .jpg is a bad idea

Why is the choice of CMS important when developing a website?
Jun 29, '25 12:34

Why is the choice of CMS important when developing a website?

Error 403 on the website: what it means and how to fix it
Jul 24, '25 23:50

Error 403 on the website: what it means and how to fix it

What is vibe coding?
Jul 25, '25 21:51

What is vibe coding?