diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-10 04:18:28 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-10 04:18:28 +0000 |
commit | aa9844cba02dc014a1bb623352c46c4520896e7f (patch) | |
tree | 408b201bd33d5660d1f80d08c3326b3447df434e /test | |
parent | b1af087d4f140dacf3aed2f5f4742eadf9ee8090 (diff) | |
download | ruby-aa9844cba02dc014a1bb623352c46c4520896e7f.tar.gz |
variable.c: fix autoload object lifetimes and leak
We must not call normal Hash methods inside GC free callback,
either, however identity hash may be used.
[ruby-core:86935] [Bug #14742]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_autoload.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb index 6d51c16927..8311c40c35 100644 --- a/test/ruby/test_autoload.rb +++ b/test/ruby/test_autoload.rb @@ -335,6 +335,18 @@ p Foo::Bar end end + def test_no_leak + assert_no_memory_leak([], '', <<~'end;', 'many autoloads', timeout: 30) + 200000.times do |i| + m = Module.new + m.instance_eval do + autoload :Foo, 'x' + autoload :Bar, i.to_s + end + end + end; + end + def add_autoload(path) (@autoload_paths ||= []) << path ::Object.class_eval {autoload(:AutoloadTest, path)} |