diff options
| author | Peter Zhu <peter@peterzhu.ca> | 2025-03-11 15:05:05 -0400 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2025-03-11 21:55:03 -0400 |
| commit | 1cdec3240b3c998c0cbf73556786aa3fa0b02ae7 (patch) | |
| tree | 2fced782c8831c25f95be7e3253fde22253886cf /spec/ruby/core/env/include_spec.rb | |
| parent | 1b2cc9c2b80da4618499ab3dd3dd70a499546c75 (diff) | |
Fix memory leak in rb_reg_search_set_match
https://github.com/ruby/ruby/pull/12801 changed regexp matches to reuse
the backref, which causes memory to leak if the original registers of the
match is not freed.
For example, the following script leaks memory:
10.times do
1_000_000.times do
"aaaaaaaaaaa".gsub(/a/, "")
end
puts `ps -o rss= -p #{$$}`
end
Before:
774256
1535152
2297360
3059280
3821296
4583552
5160304
5091456
5114256
4980192
After:
12480
11440
11696
11632
11632
11760
11824
11824
11824
11888
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12905
Diffstat (limited to 'spec/ruby/core/env/include_spec.rb')
0 files changed, 0 insertions, 0 deletions
