Project

General

Profile

Actions

Bug #19550

closed

Memory leak in iclass for 32 bit systems

Added by peterzhu2118 (Peter Zhu) about 1 year ago. Updated 10 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:113026]

Description

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:

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.

Actions #2

Updated by peterzhu2118 (Peter Zhu) about 1 year ago

  • Status changed from Open to Closed

Applied in changeset git|417b1a36447cb2c650de55b433ba623541fb8bb3.


Fix memory leak for iclass

[Bug #19550]

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:

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.

Updated by nagachika (Tomoyuki Chikanaga) 10 months ago

  • Backport changed from 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED to 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONE

ruby_3_2 9fb94407b97bb85ea344e67606f8ae9ba0bdbd48 merged revision(s) 417b1a36447cb2c650de55b433ba623541fb8bb3.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0