diff options
| author | nagachika <nagachika@ruby-lang.org> | 2023-11-19 22:00:38 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2023-11-19 22:00:38 +0900 |
| commit | 1cc38d5a2f84733e1c2e42548639e2891fe61e69 (patch) | |
| tree | 04eaa9b0e34fbf197451fc2c88b67b1a06c4ecb9 /test/ruby | |
| parent | 5baf94f9131fb45d50c8c408e007a138ced46606 (diff) | |
merge revision(s) 9eac9d71786a8dbec520d0541a91149f01adf8ea: [Backport #19969]
[Bug #19969] Compact st_table after deleted if possible
---
hash.c | 19 +++++++++++++++++++
st.c | 40 +++++++++++++++++++++++++++++-----------
test/ruby/test_hash.rb | 9 +++++++++
3 files changed, 57 insertions(+), 11 deletions(-)
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_hash.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 8b6065146c..8d36cf657f 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1758,6 +1758,15 @@ class TestHash < Test::Unit::TestCase assert_no_memory_leak([], prepare, code, bug9187) end + def test_memory_size_after_delete + require 'objspace' + h = {} + 1000.times {|i| h[i] = true} + big = ObjectSpace.memsize_of(h) + 1000.times {|i| h.delete(i)} + assert_operator ObjectSpace.memsize_of(h), :<, big/10 + end + def test_wrapper bug9381 = '[ruby-core:59638] [Bug #9381]' |
