summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-08-29 16:47:26 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-08-29 17:18:58 +0900
commita615885f1e87f4bfbc5398b060fd3a64d5de8c4a (patch)
treec0045c949a33c1e661744e8d8e9f70deb1d36629 /test/ruby
parent265a725830a487b846bc32f70346f6438c95a7e9 (diff)
Free previously used tables [Bug #18134]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4788
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_hash.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index ac0d1dfce3..f79879c20a 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -1278,6 +1278,15 @@ class TestHash < Test::Unit::TestCase
assert_raise(FrozenError) { h2.replace(42) }
end
+ def test_replace_memory_leak
+ assert_no_memory_leak([], "#{<<-"begin;"}", "#{<<-'end;'}")
+ h = ("aa".."zz").each_with_index.to_h
+ 10_000.times {h.dup}
+ begin;
+ 500_000.times {h.dup.replace(h)}
+ end;
+ end
+
def test_size2
assert_equal(0, @cls[].size)
end