mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge revision(s) a4d5ee4f31
: [Backport #18264]
[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`). --- test/ruby/test_settracefunc.rb | 10 ++++++++++ vm_trace.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)
This commit is contained in:
parent
b1696c87d3
commit
75e7499391
3 changed files with 14 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||
#define RUBY_VERSION_TEENY 3
|
||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
||||
#define RUBY_PATCHLEVEL 148
|
||||
#define RUBY_PATCHLEVEL 149
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2021
|
||||
#define RUBY_RELEASE_MONTH 10
|
||||
#define RUBY_RELEASE_DAY 31
|
||||
#define RUBY_RELEASE_MONTH 11
|
||||
#define RUBY_RELEASE_DAY 6
|
||||
|
||||
#include "ruby/version.h"
|
||||
|
||||
|
|
|
@ -730,7 +730,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
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue