Memory leak in ActionController::Metal (3.0.7)
Consider the following class:
class Myclass < ActionController::Metal def myaction huge_object.do_something # etc. end private def huge_object `@obj` ||= begin # allocate and initialize a ~10MB object end end end
What I was amazed to find, is that even in production, each time the myaction is called, the object is allocated. Moreover, something is holding a reference to it, as the GC doesn't collect it. I made a workaround by wrapping the object in other class and including Singleton in that class. Still, I want to understand, what's going on here.