aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAman Gupta <aman@tmm1.net>2010-04-04 00:20:30 -0700
committerwycats <wycats@gmail.com>2010-04-04 02:10:21 -0700
commitaf89c58696580ee26ffbd99ab9a3747fba937e35 (patch)
tree259ad2b1d398d61918f8907a38fa77b5cab54d59
parenta8c3c71af161e7d4263ad489ca2f6601bc02a9bb (diff)
downloadrails-af89c58696580ee26ffbd99ab9a3747fba937e35.tar.gz
rails-af89c58696580ee26ffbd99ab9a3747fba937e35.tar.bz2
rails-af89c58696580ee26ffbd99ab9a3747fba937e35.zip
Use a constant proc to generate ActionView::Template finalizers. For some strange reason, finalizers created via ActionView::Template.finalizer_for cause Template instances to leak on MRI.
Signed-off-by: wycats <wycats@gmail.com>
-rw-r--r--actionpack/lib/action_view/template.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index 3df2bd8eed..3c0cd35359 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -18,7 +18,7 @@ module ActionView
attr_reader :source, :identifier, :handler, :virtual_path, :formats
- def self.finalizer_for(method_name)
+ Finalizer = proc do |method_name|
proc do
ActionView::CompiledTemplates.module_eval do
remove_possible_method method_name
@@ -77,7 +77,6 @@ module ActionView
private
def compile(locals, view)
method_name = build_method_name(locals)
-
return method_name if view.respond_to?(method_name)
locals_code = locals.keys.map! { |key| "#{key} = local_assigns[:#{key}];" }.join
@@ -106,7 +105,8 @@ module ActionView
begin
ActionView::CompiledTemplates.module_eval(source, identifier, line)
- ObjectSpace.define_finalizer(self, self.class.finalizer_for(method_name))
+ ObjectSpace.define_finalizer(self, Finalizer[method_name])
+
method_name
rescue Exception => e # errors from template code
if logger = (view && view.logger)