[ruby-core:113026] [Ruby master Bug#19550] Memory leak in iclass for 32 bit systems
From:
"peterzhu2118 (Peter Zhu) via ruby-core" <ruby-core@...>
Date:
2023-03-27 18:00:32 UTC
List:
ruby-core #113026
Issue #19550 has been reported by peterzhu2118 (Peter Zhu).
----------------------------------------
Bug #19550: Memory leak in iclass for 32 bit systems
https://bugs.ruby-lang.org/issues/19550
* Author: peterzhu2118 (Peter Zhu)
* Status: Open
* Priority: Normal
* Backport: 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED
----------------------------------------
If !RCLASS_EXT_EMBEDDED (e.g. 32 bit systems) then the rb_classext_t is allocated throug malloc so it must be freed.
The issue can be seen in the following script:
```ruby
20.times do
100_000.times do
mod = Module.new
Class.new do
include mod
end
end
# Output the Resident Set Size (memory usage, in KB) of the current Ruby process
puts `ps -o rss= -p #{$$}`
end
```
Before this fix, the max RSS is 280MB, while after this change, it's 30MB.
--
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/