mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Free everything at shutdown
when the RUBY_FREE_ON_SHUTDOWN environment variable is set, manually free memory at shutdown. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Peter Zhu <peter@peterzhu.ca>
This commit is contained in:
parent
b361a800c2
commit
6816e8efcf
27 changed files with 285 additions and 6 deletions
16
marshal.c
16
marshal.c
|
@ -2517,6 +2517,20 @@ Init_marshal(void)
|
|||
rb_define_const(rb_mMarshal, "MINOR_VERSION", INT2FIX(MARSHAL_MINOR));
|
||||
}
|
||||
|
||||
static int
|
||||
free_compat_i(st_data_t key, st_data_t value, st_data_t _)
|
||||
{
|
||||
xfree((marshal_compat_t *)value);
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
static void
|
||||
free_compat_allocator_table(void *data)
|
||||
{
|
||||
st_foreach(data, free_compat_i, 0);
|
||||
st_free_table(data);
|
||||
}
|
||||
|
||||
static st_table *
|
||||
compat_allocator_table(void)
|
||||
{
|
||||
|
@ -2525,7 +2539,7 @@ compat_allocator_table(void)
|
|||
#undef RUBY_UNTYPED_DATA_WARNING
|
||||
#define RUBY_UNTYPED_DATA_WARNING 0
|
||||
compat_allocator_tbl_wrapper =
|
||||
Data_Wrap_Struct(0, mark_marshal_compat_t, 0, compat_allocator_tbl);
|
||||
Data_Wrap_Struct(0, mark_marshal_compat_t, free_compat_allocator_table, compat_allocator_tbl);
|
||||
rb_gc_register_mark_object(compat_allocator_tbl_wrapper);
|
||||
return compat_allocator_tbl;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue