From 454f89e2ea99044590f7be1e9a9993cd9689f8cd Mon Sep 17 00:00:00 2001 From: marcandre Date: Wed, 4 Feb 2015 19:03:04 +0000 Subject: * vm_insnhelper.c: Fix one type of symbol leak with +send+ git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_symbol.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb index 596f2b09f6..db0d135b90 100644 --- a/test/ruby/test_symbol.rb +++ b/test/ruby/test_symbol.rb @@ -238,4 +238,24 @@ class TestSymbol < Test::Unit::TestCase 200_000.times { |i| i.to_s.to_sym } end; end + + def assert_no_immortal_symbol_created + delta = -Symbol.all_symbols.size + yield + GC.start + delta += Symbol.all_symbols.size + assert_equal 0, delta, "#{delta} immortal symbols were created" + end + + def test_symbol_send_leak_string + assert_no_immortal_symbol_created do + 10.times { 42.send "send should not leak #{i} - str" rescue nil } + end + end + + def test_symbol_send_leak_symbol + assert_no_immortal_symbol_created do + 10.times { 42.send "send should not leak #{i} - sym".to_sym rescue nil } + end + end end -- cgit v1.2.3