summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2021-10-22 14:03:23 -0400
committerPeter Zhu <peter@peterzhu.ca>2021-10-26 13:11:35 -0400
commita4d5ee4f31bf3ff36c1a8c8fe3cda16aa1016b12 (patch)
tree6f33dc0b4e7f95704a28ad4477fb4ab5f759470c /test/ruby
parentf180fa6ca3f0972413ed37a72cde7b202a7ba85f (diff)
[Bug #18264] Fix memory leak in TracePoint
TracePoint leaks memory because it allocates a `rb_tp_t` struct without ever freeing it (it is created with `RUBY_TYPED_NEVER_FREE`).
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5008
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_settracefunc.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index 88488aef5c..c6955467c4 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -564,6 +564,16 @@ class TestSetTraceFunc < Test::Unit::TestCase
}
end
+ # Bug #18264
+ def test_tracpoint_memory_leak
+ assert_no_memory_leak([], <<-PREP, <<-CODE, rss: true)
+code = proc { TracePoint.new(:line) { } }
+1_000.times(&code)
+PREP
+1_000_000.times(&code)
+CODE
+ end
+
def trace_by_set_trace_func
events = []
trace = nil