Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
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 this talk titled "Automatically Find Memory Leaks in Native Gems," Peter Zhu, a senior developer at Shopify and a member of the Ruby core team, discusses the challenge of detecting memory leaks in Native gems—libraries that integrate lower-level programming languages like C within Ruby applications. Memory leaks occur when allocated memory is not properly released back to the system, which can lead to significant performance issues, especially in web servers running Ruby on Rails. **Key Points Discussed:** - **Understanding Native Gems:** Native gems improve performance by leveraging lower-level languages, but they lack automatic garbage collection, requiring developers to manage memory manually. - **Consequences of Memory Leaks:** Zhu illustrates the impact of memory leaks through an analysis of a memory usage graph from a Shopify service, showcasing linear memory growth followed by catastrophic container shutdowns on Kubernetes due to out-of-memory issues. - **The Discovery of Memory Leaks:** Zhu recounts discovering a memory leak in "Liquid C," a gem used by Shopify, which prompted the need to develop a reliable tool to find such leaks efficiently. - **Introducing Ruby Memcheck:** The tool integrates with developers' test suites like MiniTest or RSpec and uses Valgrind’s Memcheck to detect memory leaks. Zhu details how Valgrind tracks allocations and identifies leaks during shutdown but notes its limitations in a Ruby context. - **Heuristics Employed by Ruby Memcheck:** The presentation explains several heuristics Ruby Memcheck uses to filter out false positives in memory leak detection, including filtering stack traces to confirm allocations originate from within the native gem and checking for Ruby's own memory allocations. - **Limitations of the Tool:** Zhu addresses the limitations of Ruby Memcheck, such as its reliance on Linux, performance impacts with Valgrind, and its inability to catch certain types of memory leaks. - **Successful Implementation:** Zhu presents successful cases where Ruby Memcheck identified memory leaks not only in Liquid C but also in other libraries like Nokogiri and Rotoscope, proving its effectiveness. **Conclusion and Call to Action:** Zhu encourages native gem maintainers to implement Ruby Memcheck, emphasizing that while it may take effort to address any detected leaks, the tool is designed to be easy to integrate, thereby helping improve the overall stability and efficiency of Ruby applications. He invites developers to explore Ruby Memcheck on GitHub and share their experiences. In summary, this talk highlights the importance of tackling memory leaks in Native gems and promotes an effective solution for developers to maintain robust Ruby applications.
Suggest modifications
Cancel