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

View file

@ -22,6 +22,9 @@ void rb_jit_cont_init(void);
void rb_jit_cont_each_iseq(rb_iseq_callback callback, void *data);
void rb_jit_cont_finish(void);
/* vm.c */
void rb_free_shared_fiber_pool(void);
// Copy locals from the current execution to the specified fiber.
VALUE rb_fiber_inherit_storage(struct rb_execution_context_struct *ec, struct rb_fiber_struct *fiber);

View file

@ -29,4 +29,7 @@ void rb_enc_set_base(const char *name, const char *orig);
int rb_enc_set_dummy(int index);
PUREFUNC(int rb_data_is_encoding(VALUE obj));
/* vm.c */
void rb_free_global_enc_table(void);
#endif /* INTERNAL_ENCODING_H */

View file

@ -169,6 +169,9 @@ VALUE rb_syserr_new_path_in(const char *func_name, int n, VALUE path);
#endif
RUBY_SYMBOL_EXPORT_END
/* vm.c */
void rb_free_warning(void);
static inline void
rb_raise_cstr_i(VALUE etype, VALUE mesg)
{

View file

@ -12,5 +12,6 @@
/* random.c */
int ruby_fill_random_bytes(void *, size_t, int);
void rb_free_default_rand_key(void);
#endif /* INTERNAL_RANDOM_H */

View file

@ -32,6 +32,9 @@ ID rb_make_temporary_id(size_t n);
void rb_gc_free_dsymbol(VALUE);
int rb_static_id_valid_p(ID id);
/* vm.c */
void rb_free_static_symid_str(void);
#if __has_builtin(__builtin_constant_p)
#define rb_sym_intern_ascii_cstr(ptr) \
(__builtin_constant_p(ptr) ? \

View file

@ -17,4 +17,7 @@
extern VALUE rb_cEncodingConverter;
size_t rb_econv_memsize(rb_econv_t *);
/* vm.c */
void rb_free_transcoder_table(void);
#endif /* INTERNAL_TRANSCODE_H */

View file

@ -83,6 +83,11 @@ void rb_check_stack_overflow(void);
extern uint64_t rb_vm_insns_count;
#endif
extern bool rb_free_on_exit;
/* miniinit.c and builtin.c */
void rb_free_loaded_builtin_table(void);
/* vm_insnhelper.c */
VALUE rb_equal_opt(VALUE obj1, VALUE obj2);
VALUE rb_eql_opt(VALUE obj1, VALUE obj2);