diff options
| author | NARUSE, Yui <nurse@users.noreply.github.com> | 2024-03-21 11:23:21 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-21 02:23:21 +0000 |
| commit | 57a0afe2090b8d05673d650b1e8bf9ae67449b1f (patch) | |
| tree | e0395ca2411d6a3104150dda990495901400f6a1 /test/ruby | |
| parent | 821719a505bbc628ddd80b90ae892666006eada1 (diff) | |
merge revision(s) 081ee3d35509110f383cb7dd8d1205def0cdd1e8,1c97abaabae6844c861705fd07f532292dcffa74: [Backport #19907] (#10315)
Add memory leak test for eval kwargs
De-dup identical callinfo objects
Previously every call to vm_ci_new (when the CI was not packable) would
result in a different callinfo being returned this meant that every
kwarg callsite had its own CI.
When calling, different CIs result in different CCs. These CIs and CCs
both end up persisted on the T_CLASS inside cc_tbl. So in an eval loop
this resulted in a memory leak of both types of object. This also likely
resulted in extra memory used, and extra time searching, in non-eval
cases.
For simplicity in this commit I always allocate a CI object inside
rb_vm_ci_lookup, but ideally we would lazily allocate it only when
needed. I hope to do that as a follow up in the future.
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_method.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index b22dd9cbee..90635bc5e5 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -1614,4 +1614,12 @@ class TestMethod < Test::Unit::TestCase def test_invalidating_CC_ASAN assert_ruby_status(['-e', 'using Module.new']) end + + def test_kwarg_eval_memory_leak + assert_no_memory_leak([], "", <<~RUBY, rss: true, limit: 1.2) + 100_000.times do + eval("Hash.new(foo: 123)") + end + RUBY + end end |
