Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
What causes Ruby memory bloat? Ruby apps can use a lot of memory. But why? I set out on a journey of discovery, and not only found evidence that defies common wisdom, but also a simple way to reduce memory usage by 70%. Hongli Lai - https://twitter.com/honglilai EuRuKo 2019
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In the EuRuKo 2019 talk titled "What causes Ruby memory bloat?", speaker Hongli Lai, the creator of Passenger, delves into the significant issue of memory usage in Ruby applications. The discussion is centered around unexpected memory bloat observed in Ruby, particularly in multi-threaded environments, and offers insights and solutions to mitigate this problem. Key points discussed in the video include: - **Understanding Memory Allocation**: The presentation starts with an explanation of how memory allocation works at a basic level. It covers the roles of the operating system and the user space memory allocator in managing memory, including the concept of OS pages and Ruby heap pages. - **Investigation of Memory Bloat**: Hongli recounts his experience with a simple Ruby proxy application that exhibited excessive memory usage, prompting him to investigate the causes of this bloat. He identifies memory fragmentation and inefficient memory allocation practices as the primary culprits. - **The Role of Threads**: The talk highlights the irony of multi-threading in Ruby, where it is expected to enhance concurrency without significantly increasing memory usage. However, the challenges arise mostly in multi-threaded applications on Linux. - **Memory Usage Discrepancy**: A significant revelation during the presentation is the actual distribution of memory usage, where only a small fraction is attributed to Ruby objects compared to the overall memory reported by the OS, suggesting that the memory allocator's inefficiency is partly to blame. - **Potential Solutions**: Lai discusses practical solutions, such as using specific environment variables to optimize memory allocation and the benefits of using memory allocators like jemalloc. He emphasizes the importance of the malloc_trim() function to help release unused memory back to the system, which can help reduce fragmentation. - **Announcement of Full Stack Ruby**: To put his findings into practice, Lai announces the development of a new Ruby distribution, Full Stack Ruby, which integrates these memory optimization techniques. This distribution aims to simplify memory management for Ruby developers. In conclusion, Hongli Lai's presentation sheds light on the complexities of memory management in Ruby applications, particularly under multi-threaded conditions. The presentation advocates for further exploration of memory optimizations within the Ruby community, encouraging developers to stay informed and participate in improving memory management practices. Ultimately, sustaining the performance of Ruby applications while reducing memory usage is a collective goal that Hongli hopes to achieve with his proposed solutions and new tooling.
Suggest modifications
Cancel