From: "peterzhu2118 (Peter Zhu) via ruby-core" Date: 2024-07-24T19:19:48+00:00 Subject: [ruby-core:118680] [Ruby master Bug#20650] Memory leak in Regexp capture group when timeout Issue #20650 has been reported by peterzhu2118 (Peter Zhu). ---------------------------------------- Bug #20650: Memory leak in Regexp capture group when timeout https://bugs.ruby-lang.org/issues/20650 * Author: peterzhu2118 (Peter Zhu) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: REQUIRED, 3.3: REQUIRED ---------------------------------------- GitHub PR: https://github.com/ruby/ruby/pull/11238 The capture group allocates memory that is leaked when it times out. For example: ```ruby re = Regexp.new("^#{"(a*)" * 10_000}x$", timeout: 0.000001) str = "a" * 1000000 + "x" 10.times do 100.times do re =~ str rescue Regexp::TimeoutError end puts `ps -o rss= -p #{$$}` end ``` Before: ``` 34688 56416 78288 100368 120784 140704 161904 183568 204320 224800 ``` After: ``` 16288 16288 16880 16896 16912 16928 16944 17184 17184 17200 ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/