The CRuby interpreter manages its memory in a complex and interesting way. Knowing about it can help you optimise your Ruby programs and also just generally understand what's going on.
Learn how Ruby encodes objects in memory and how to optimise for it.
After watching the video, here's a deeper (text) explanation of tiny, small and large Ruby objects in memory.
Ruby 'tiny' objects, such as integers and floating-point numbers are encoded directly into the 64-bit reference that would otherwise point to a value. What can those references contain? How are they encoded?
Nate Berkopec explains Ruby memory fragmentation and how it can waste your memory. He also tells you how to detect and avoid it.
Ruby uses a normal system allocator for most of its memory. That means GCC's allocator, or you can configure another like TCMalloc or jemalloc. What are the performance implications? Should you do so? (Spoiler: yes)
Here, Nate Berkopec gives a lot of interesting tricks to reduce your memory usage in Ruby. Each shows you something about how Ruby's memory system operates.
Ruby allows you to configure a lot of its memory handling with environment variables. Which variables? What do they do?
Looking for similar topics?