diff options
author | Peter Zhu <[email protected]> | 2024-01-08 11:32:48 -0500 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2024-01-10 11:20:26 -0500 |
commit | 82b57d7bfeefd717c10f7a5a3484aca6b3e708a3 (patch) | |
tree | 29dd965c9e8347f2de3656e4543bc916127dd282 /yjit.c | |
parent | f165fa09e7bc36f90d3862e537f071f0e1339428 (diff) |
Fix memory leak when duplicating too complex object
[Bug #20162]
Creating a ST table then calling st_replace leaks memory because the
st_replace overwrites the ST table without freeing any of the existing
memory. This commit changes it to use st_copy instead.
For example:
RubyVM::Shape.exhaust_shapes
o = Object.new
o.instance_variable_set(:@a, 0)
10.times do
100_000.times { o.dup }
puts `ps -o rss= -p #{$$}`
end
Before:
23264
33600
42672
52160
61600
71728
81056
90528
100560
109840
After:
14752
14816
15584
15584
15664
15664
15664
15664
15664
15664
Diffstat (limited to 'yjit.c')
0 files changed, 0 insertions, 0 deletions