зеркало из https://github.com/github/ruby.git
[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:
Родитель
f180fa6ca3
Коммит
a4d5ee4f31
|
@ -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
|
||||
|
|
|
@ -748,7 +748,7 @@ tp_memsize(const void *ptr)
|
|||
|
||||
static const rb_data_type_t tp_data_type = {
|
||||
"tracepoint",
|
||||
{tp_mark, RUBY_TYPED_NEVER_FREE, tp_memsize,},
|
||||
{tp_mark, RUBY_TYPED_DEFAULT_FREE, tp_memsize,},
|
||||
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче