From b29e89368841869c92d706addddd09f436a3ea2f Mon Sep 17 00:00:00 2001 From: wycats Date: Fri, 2 Apr 2010 19:21:19 -0700 Subject: Fix memory leak in dev mode --- actionpack/lib/action_view/template.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index 8abc1633ff..3df2bd8eed 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -18,6 +18,14 @@ module ActionView attr_reader :source, :identifier, :handler, :virtual_path, :formats + def self.finalizer_for(method_name) + proc do + ActionView::CompiledTemplates.module_eval do + remove_possible_method method_name + end + end + end + def initialize(source, identifier, handler, details) @source = source @identifier = identifier @@ -98,6 +106,7 @@ module ActionView begin ActionView::CompiledTemplates.module_eval(source, identifier, line) + ObjectSpace.define_finalizer(self, self.class.finalizer_for(method_name)) method_name rescue Exception => e # errors from template code if logger = (view && view.logger) -- cgit v1.2.3