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:
Adam Hess 2023-10-12 11:15:53 -07:00 committed by Peter Zhu
parent b361a800c2
commit 6816e8efcf
27 changed files with 285 additions and 6 deletions

5
ruby.c
View file

@ -1754,6 +1754,11 @@ ruby_opt_init(ruby_cmdline_options_t *opt)
"environment variables RUBY_GC_HEAP_%d_INIT_SLOTS");
}
if (getenv("RUBY_FREE_ON_EXIT")) {
rb_warn("Free on exit is experimental and may be unstable");
rb_free_on_exit = true;
}
#if USE_RJIT
// rb_call_builtin_inits depends on RubyVM::RJIT.enabled?
if (opt->rjit.on)