diff options
author | Peter Zhu <[email protected]> | 2025-03-11 15:05:05 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2025-03-11 21:55:03 -0400 |
commit | 1cdec3240b3c998c0cbf73556786aa3fa0b02ae7 () | |
tree | 2fced782c8831c25f95be7e3253fde22253886cf /test | |
parent | 1b2cc9c2b80da4618499ab3dd3dd70a499546c75 (diff) |
Fix memory in rb_reg_search_set_match
https://.com/ruby/ruby/pull/12801 changed regexp matches to reuse the backref, which causes memory to if the original registers of the match is not freed. For example, the following script s 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: Merged: https://.com/ruby/ruby/pull/12905
-rw-r--r-- | test/ruby/test_regexp.rb | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -999,6 +999,18 @@ class TestRegexp < Test::Unit::TestCase assert_equal('foobazquux/foobazquux', result, bug8856) end def test_ignorecase v = assert_deprecated_warning(/variable \$= is no longer effective/) { $= } assert_equal(false, v) |