Project

General

Profile

Actions

Bug #18264

closed

TracePoint leaks memory

Added by peterzhu2118 (Peter Zhu) about 3 years ago. Updated about 3 years ago.

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

Description

GitHub PR: https://github.com/ruby/ruby/pull/5008

TracePoint leaks memory because it allocates a rb_tp_t struct without ever freeing it (it is created with RUBY_TYPED_NEVER_FREE). This is reproducible on all maintained Rubies (2.6.8, 2.7.4, 3.0.2, master) on Ubuntu 20.04.

The follow string demonstrates the issue.

100.times do
  10000.times do
    TracePoint.new(:line) {}
  end

  # Output the Resident Set Size (memory usage, in KB) of the current Ruby process
  puts `ps -o rss= -p #{$$}`
end

We can see the leak through the following graph of the Resident Set Size (RSS) comparing the branch vs. master (at commit 6b9285e8d45e88c5b014b8428520ffa2401789ad).

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0