aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-06-30 06:11:26 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-06-30 06:11:26 +0000
commit7e1d002673777bb1240e27949a853a8f287d1f56 (patch)
treede22db895d036c0729d61eb8ace57d2a53859428 /activesupport/lib/active_support
parenta90598b4581987297e425914096d6bf134957d17 (diff)
downloadrails-7e1d002673777bb1240e27949a853a8f287d1f56.tar.gz
rails-7e1d002673777bb1240e27949a853a8f287d1f56.tar.bz2
rails-7e1d002673777bb1240e27949a853a8f287d1f56.zip
Fixed memory leak with Object#remove_subclasses_of, which inflicted a Rails application running in development mode with a ~20KB leak per request #1289 [c.r.mcgrath@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1569 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/object_and_class.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/object_and_class.rb b/activesupport/lib/active_support/core_ext/object_and_class.rb
index b8e9d27217..968c3bdeac 100644
--- a/activesupport/lib/active_support/core_ext/object_and_class.rb
+++ b/activesupport/lib/active_support/core_ext/object_and_class.rb
@@ -1,6 +1,13 @@
class Object #:nodoc:
def remove_subclasses_of(superclass)
- subclasses_of(superclass).each { |subclass| Object.send(:remove_const, subclass) rescue nil }
+ subclasses_of(superclass).each do |subclass|
+ ObjectSpace.each_object(Class) do |k|
+ if k.to_s == subclass
+ k.instance_variables.each { |v| k.send(:remove_instance_variable, v) }
+ end
+ end
+ Object.send(:remove_const, subclass) rescue nil
+ end
end
def subclasses_of(superclass)