From 856903850bf86932f7994da799479eb9c1550041 Mon Sep 17 00:00:00 2001 From: normal Date: Sat, 13 Dec 2014 01:28:18 +0000 Subject: gc.c (define_final0): avoid duplicate blocks This prevents excessive memory growth when a WeakRef is repeatedly created * gc.c (define_final0): avoid duplicate blocks [Bug #10537] * test/test_weakref.rb (test_repeated_object_leak): new test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/test_weakref.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/test_weakref.rb') diff --git a/test/test_weakref.rb b/test/test_weakref.rb index 129c1e6ed1..36b5d5bc51 100644 --- a/test/test_weakref.rb +++ b/test/test_weakref.rb @@ -60,4 +60,12 @@ class TestWeakRef < Test::Unit::TestCase end }, bug7304 end + + def test_repeated_object_leak + bug10537 = '[ruby-core:66428]' + assert_no_memory_leak(%w(-rweakref), '', <<-'end;', bug10537) + a = Object.new + 150_000.times { WeakRef.new(a) } + end; + end end -- cgit v1.2.3