diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-20 11:23:13 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-20 11:23:13 +0000 |
commit | 6a519401176126cd808aa5e3562a21f34a64de65 (patch) | |
tree | 7da966acceedfb11ceb234d796fa0250033fa6b3 /activesupport | |
parent | 8a35865b747e0e96ae53e45997d6742f8f0ccfc3 (diff) | |
download | rails-6a519401176126cd808aa5e3562a21f34a64de65.tar.gz rails-6a519401176126cd808aa5e3562a21f34a64de65.tar.bz2 rails-6a519401176126cd808aa5e3562a21f34a64de65.zip |
Fixed memory leak with Active Record classes when Dependencies.mechanism = :load #1704 [c.r.mcgrath@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2276 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/object_and_class.rb | 9 | ||||
-rw-r--r-- | activesupport/test/core_ext/object_and_class_ext_test.rb | 46 |
3 files changed, 2 insertions, 55 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index 62686e8e75..955772376f 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed memory leak with Active Record classes when Dependencies.mechanism = :load #1704 [c.r.mcgrath@gmail.com] + * Fixed Inflector.underscore for use with acronyms, so HTML becomes html instead of htm_l #2173 [k@v2studio.com] * Fixed dependencies related infinite recursion bug when a controller file does not contain a controller class. Closes #1760. [rcolli2@tampabay.rr.com] 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 4ad13265d7..cff8fca5bb 100644 --- a/activesupport/lib/active_support/core_ext/object_and_class.rb +++ b/activesupport/lib/active_support/core_ext/object_and_class.rb @@ -1,19 +1,10 @@ class Object #:nodoc: def remove_subclasses_of(*superclasses) subclasses_of(*superclasses).each do |subclass| - subclass.instance_variables.each { |v| subclass.send(:remove_instance_variable, v) } Object.send(:remove_const, subclass.to_s) rescue nil end end - def remove_instance_variables_of(klass) - ObjectSpace.each_object(Class) do |k| - if k.to_s == klass - k.instance_variables.each { |v| k.send(:remove_instance_variable, v) } - end - end - end - def subclasses_of(*superclasses) subclasses = [] ObjectSpace.each_object(Class) do |k| diff --git a/activesupport/test/core_ext/object_and_class_ext_test.rb b/activesupport/test/core_ext/object_and_class_ext_test.rb index 29b2f2fc8b..29e18d5ae1 100644 --- a/activesupport/test/core_ext/object_and_class_ext_test.rb +++ b/activesupport/test/core_ext/object_and_class_ext_test.rb @@ -5,27 +5,6 @@ class ClassA; end class ClassB < ClassA; end class ClassC < ClassB; end class ClassD < ClassA; end -class RemoveSubsTestClass; end -class RemoveSubsBaseClass - def self.add_ivar - @ivar = RemoveSubsTestClass.new - end -end -class RemoveSubsSubClass < RemoveSubsBaseClass; end -class RemoveSubsTestClass2; end -class RemoveSubsBaseClass2 - def self.add_ivar - @ivar = RemoveSubsTestClass2.new - end -end -class RemoveSubsSubClass2 < RemoveSubsBaseClass2; end -class RemoveSubsTestClass3; end -class RemoveSubsBaseClass3 - def self.add_ivar - @ivar = RemoveSubsTestClass3.new - end -end -class RemoveSubsSubClass3 < RemoveSubsBaseClass3; end class ClassExtTest < Test::Unit::TestCase def test_methods @@ -51,29 +30,4 @@ class ObjectTests < Test::Unit::TestCase suppress(LoadError, ArgumentError) { raise LoadError } suppress(LoadError, ArgumentError) { raise ArgumentError } end - - def test_remove_subclasses_of_unsets_ivars - r = RemoveSubsSubClass.new - RemoveSubsSubClass.add_ivar - RemoveSubsBaseClass.remove_subclasses - - GC.start - ObjectSpace.each_object do |o| - flunk("ObjectSpace still contains RemoveSubsTestClass") if o.class == RemoveSubsTestClass - end - end - - def test_remove_subclasses_of_multiple_classes_unsets_ivars - r2 = RemoveSubsSubClass2.new - RemoveSubsSubClass2.add_ivar - r3 = RemoveSubsSubClass3.new - RemoveSubsSubClass3.add_ivar - - Object.remove_subclasses_of(RemoveSubsBaseClass2, RemoveSubsBaseClass3) - - GC.start - ObjectSpace.each_object do |o| - flunk("ObjectSpace still contains RemoveSubsTestClass") if o.class == RemoveSubsTestClass - end - end end |