summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2023-06-29 11:52:48 -0400
committerPeter Zhu <peter@peterzhu.ca>2023-06-29 11:52:48 -0400
commitbf2c18731d50075bb64e2639c097396276196cd9 (patch)
treec7bfd68289c094b8190cfcfae4e366227af16d8b /test/ruby
parentf0d08d11dcd404f3146c0d71d6ff743bbc6e7193 (diff)
Add memory leak test for allocating ST hashes
Test for commit f0d08d11dcd404f3146c0d71d6ff743bbc6e7193.
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 d9d1ca7dde..e66beef29f 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -219,6 +219,15 @@ class TestHash < Test::Unit::TestCase
assert_equal('default', h['spurious'])
end
+ def test_st_literal_memory_leak
+ assert_no_memory_leak([], "", "#{<<~'end;'}", rss: true)
+ 1_000_000.times do
+ # >8 element hashes are ST allocated rather than AR allocated
+ {a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9}
+ end
+ end;
+ end
+
def test_try_convert
assert_equal({1=>2}, Hash.try_convert({1=>2}))
assert_equal(nil, Hash.try_convert("1=>2"))