Fix RUBY_FREE_AT_EXIT for static symbols

Since static symbols allocate memory, we should deallocate them at shutdown
to prevent memory leaks from being reported with RUBY_FREE_AT_EXIT.
This commit is contained in:
Peter Zhu 2025-08-05 11:05:23 -04:00
parent 0e33256c8e
commit 95320f1ddf
3 changed files with 16 additions and 0 deletions

View file

@ -386,6 +386,20 @@ rb_sym_global_symbols_update_references(void)
symbols->ids = rb_gc_location(symbols->ids);
}
static int
rb_free_global_symbol_table_i(VALUE *sym_ptr, void *data)
{
sym_set_free(*sym_ptr);
return ST_DELETE;
}
void
rb_free_global_symbol_table(void)
{
rb_concurrent_set_foreach_with_replace(ruby_global_symbols.sym_set, rb_free_global_symbol_table_i, NULL);
}
WARN_UNUSED_RESULT(static ID lookup_str_id(VALUE str));
WARN_UNUSED_RESULT(static VALUE lookup_id_str(ID id));