From 6816e8efcff3be75f8020cd1b0ea57d3cd664bbc Mon Sep 17 00:00:00 2001 From: Adam Hess Date: Thu, 12 Oct 2023 11:15:53 -0700 Subject: Free everything at shutdown when the RUBY_FREE_ON_SHUTDOWN environment variable is set, manually free memory at shutdown. Co-authored-by: Nobuyoshi Nakada Co-authored-by: Peter Zhu --- ruby.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ruby.c') diff --git a/ruby.c b/ruby.c index a161bcb3d6..db25e1bc33 100644 --- a/ruby.c +++ b/ruby.c @@ -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) -- cgit v1.2.3