mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[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`).
This commit is contained in:
parent
f180fa6ca3
commit
a4d5ee4f31
Notes:
git
2021-10-27 02:11:55 +09:00
2 changed files with 11 additions and 1 deletions
|
@ -564,6 +564,16 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
end
|
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
|
def trace_by_set_trace_func
|
||||||
events = []
|
events = []
|
||||||
trace = nil
|
trace = nil
|
||||||
|
|
|
@ -748,7 +748,7 @@ tp_memsize(const void *ptr)
|
||||||
|
|
||||||
static const rb_data_type_t tp_data_type = {
|
static const rb_data_type_t tp_data_type = {
|
||||||
"tracepoint",
|
"tracepoint",
|
||||||
{tp_mark, RUBY_TYPED_NEVER_FREE, tp_memsize,},
|
{tp_mark, RUBY_TYPED_DEFAULT_FREE, tp_memsize,},
|
||||||
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue