← Back to context

Comment by byroot

2 days ago

There's no need for ref counting, since Ruby has a mark & sweep GC.

The interned string table uses weak references. Any string added to the interned string tables has the `FL_FSTR` flag set to it, and when a string a freed, if it has that flag the GC knowns to remove it from the interned string table.

The keyword to know to search for this in the VM is `fstring`, that's what interned strings are called internally:

- https://github.com/ruby/ruby/blob/b146eae3b5e9154d3fb692e8fe...

- https://github.com/ruby/ruby/blob/b146eae3b5e9154d3fb692e8fe...

Ah, the value of FL_FSTR was what I was missing, I had followed this code into rb_gc_free_fstring without realizing what FL_FSTR meant. Thank you!