~/talk

Memory Fragmentation and Bloat in Ruby

Talkat RubyKaigi 2017 · 2017-09-18..09-20· [ruby-on-rails]
slides:none on file

Explains why Ruby processes hold peak memory (bloat) and slowly grow (fragmentation), names the allocator and per-thread arenas as culprits, and gives concrete diagnostics and fixes: compute fragmentation with GC.stat live slots percentage (live slots ÷ eden slots), experiment with the environment variable malloc_arena_max to cap per-thread arenas, switch to jemalloc via LD_PRELOAD to cut fragmentation, avoid large in-memory collections and map that double memory, and shows a Sidekiq case where reducing arenas halves RSS from ~1GB to ~512MB.

AI-written summary · about

  1. 0:00Introduction
  2. 1:03Why memory matters in Ruby
  3. 4:21Understanding memory bloat
  4. 8:54How malloc affects memory
  5. 13:50Ruby's memory safety philosophy
  6. 14:32What is memory fragmentation
  7. 18:03Fragmentation vs memory leaks
  8. 20:14Measuring fragmentation with GC.stat
  9. 27:01Fragmentation in Ruby's heap
  10. 28:28Per-thread memory arenas issue
  11. 33:08Tuning malloc arena max
  12. 35:36Solutions to reduce fragmentation
  13. 37:22Alternative allocators like jemalloc
  14. 38:28Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.