I have the following class:
class Myclass < ActionController::Metal
def myaction
huge_object.do_something
end
private
def huge_object
@obj ||= begin
end
end
end
What I was amazed at is that even in the production process, every time myaction is called, the object is allocated. Moreover, something holds a link to it, since the GC does not collect it. I made a workaround by wrapping the object in another class and including Singleton in this class. However, I want to understand what is happening here.
Roman source
share