# Most Memory Leaks are Good

DevFeed: [Most Memory Leaks are Good](<https://devfeed.tech/articles/most-memory-leaks-are-good-1268.md>)

Original publisher: [Read original article](<https://shopify.engineering/17488512-most-memory-leaks-are-good>)

Author: Shopify Engineering

Published: 2011-10-14T16:32:00Z

Content type: article

Language: en

Sources: [Shopify Engineering](<https://devfeed.tech/sources/shopify-engineering.md>), [Shopify Engineering - Shopify Engineering](<https://devfeed.tech/sources/shopify-engineering-shopify-engineering.md>)

Topics: [Memory Leaks](<https://devfeed.tech/topics/memory-leaks.md>), [Ruby](<https://devfeed.tech/topics/ruby.md>), [Rails](<https://devfeed.tech/topics/rails.md>), [debugging](<https://devfeed.tech/topics/debugging.md>), [C](<https://devfeed.tech/topics/c.md>), [Tooling](<https://devfeed.tech/topics/tooling.md>)

Tags: [c](<https://devfeed.tech/tags/c.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [exceptions](<https://devfeed.tech/tags/exceptions.md>), [memory-leaks](<https://devfeed.tech/tags/memory-leaks.md>), [rails](<https://devfeed.tech/tags/rails.md>), [shopify](<https://devfeed.tech/tags/shopify.md>)

## AI overview

This article explains that memory allocated permanently is not always a defect: globals and constants in Ruby are intentional examples. It distinguishes these cases from leaks that repeatedly allocate memory without freeing it, such as appending to a constant on every Rails web request. The article discusses debugging approaches and language-specific tools for locating leaks in Ruby and C, including memprof and Valgrind, and describes a severe memory leak experienced at Shopify.

## Source excerpt

TL;DR Catastrophe! Your app is leaking memory. When it runs in production it crashes and starts raising Errno::ENOMEM exceptions. So you babysit it and restart it consistently so that your app keeps responding. As hard as you try you don't see any memory leaks. You use the available tools, but you can't find the leak. Understanding your full stack, knowing your tools, and good ol' debugging will help you find that memory leak. Memory leaks are good? Yes! Depending on your definition.