From: "nagachika (Tomoyuki Chikanaga) via ruby-core" Date: 2023-03-21T07:49:37+00:00 Subject: [ruby-core:112962] [Ruby master Bug#19398] Memory leak in WeakMap Issue #19398 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED, 3.2: DONE to 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE, 3.2: DONE ruby_3_1 0d00732d39de1e5ecce738260a1e49d8af52e12a merged revision(s) c6f84e918943a0bf8db6fee556fc53180d257510. ---------------------------------------- Bug #19398: Memory leak in WeakMap https://bugs.ruby-lang.org/issues/19398#change-102489 * Author: peterzhu2118 (Peter Zhu) * Status: Closed * Priority: Normal * Backport: 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE, 3.2: DONE ---------------------------------------- Pull request: https://github.com/ruby/ruby/pull/7223 There's a memory leak in ObjectSpace::WeakMap due to not freeing the `struct weakmap`. It can be seen in the following script: ```ruby 100.times do 10000.times do ObjectSpace::WeakMap.new end # Output the Resident Set Size (memory usage, in KB) of the current Ruby process puts `ps -o rss= -p #{$$}` end ``` This is the memory usage graph before and after the patch: ![](chart.png) ---Files-------------------------------- chart.png (26.9 KB) -- 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/postorius/lists/ruby-core.ml.ruby-lang.org/