зеркало из https://github.com/github/ruby.git
fix leak in module clone Co-authored-by: Peter Zhu <peter@peterzhu.ca>
This commit is contained in:
Родитель
61a2e9450c
Коммит
c42261059d
1
class.c
1
class.c
|
@ -471,6 +471,7 @@ copy_tables(VALUE clone, VALUE orig)
|
|||
rb_id_table_foreach(rb_cvc_tbl, cvc_table_copy, &ctx);
|
||||
RCLASS_CVC_TBL(clone) = rb_cvc_tbl_dup;
|
||||
}
|
||||
rb_id_table_free(RCLASS_M_TBL(clone));
|
||||
RCLASS_M_TBL(clone) = 0;
|
||||
if (!RB_TYPE_P(clone, T_ICLASS)) {
|
||||
st_data_t id;
|
||||
|
|
|
@ -3321,6 +3321,18 @@ class TestModule < Test::Unit::TestCase
|
|||
CODE
|
||||
end
|
||||
|
||||
def test_module_clone_memory_leak
|
||||
# [Bug #19901]
|
||||
assert_no_memory_leak([], <<~PREP, <<~CODE, rss: true)
|
||||
code = proc do
|
||||
Module.new.clone
|
||||
end
|
||||
1_000.times(&code)
|
||||
PREP
|
||||
1_000_000.times(&code)
|
||||
CODE
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_top_method_is_private(method)
|
||||
|
|
Загрузка…
Ссылка в новой задаче