
Issue #19398 has been reported by peterzhu2118 (Peter Zhu). ---------------------------------------- Bug #19398: Memory leak in WeakMap https://bugs.ruby-lang.org/issues/19398 * Author: peterzhu2118 (Peter Zhu) * Status: Open * Priority: Normal * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- 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:  ---Files-------------------------------- chart.png (26.9 KB) -- https://bugs.ruby-lang.org/