Skip to content
Browse files

Revert "removing crazy finalizer code until there is proof that we ne…

…ed it"

This reverts commit a40e3c1.
  • Loading branch information...
1 parent 6b248f6 commit 6a55ca346e543e4e112648cca2a01230c32b21ec @josevalim josevalim committed
Showing with 11 additions and 0 deletions.
  1. +11 −0 actionpack/lib/action_view/template.rb
View
11 actionpack/lib/action_view/template.rb
@@ -101,6 +101,16 @@ class Template
attr_reader :source, :identifier, :handler, :virtual_path, :formats,
:original_encoding
+ # This finalizer is needed (and exactly with a proc inside another proc)
+ # otherwise templates leak in development.
+ Finalizer = proc do |method_name, mod|
+ proc do
+ mod.module_eval do
+ remove_possible_method method_name
+ end
+ end
+ end
+
def initialize(source, identifier, handler, details)
@source = source
@identifier = identifier
@@ -245,6 +255,7 @@ def #{method_name}(local_assigns)
begin
mod.module_eval(source, identifier, 0)
+ ObjectSpace.define_finalizer(self, Finalizer[method_name, mod])
method_name
rescue Exception => e # errors from template code

0 comments on commit 6a55ca3

Please sign in to comment.
Something went wrong with that request. Please try again.