chibi-scheme
chibi-scheme copied to clipboard
Garbage collection of symbols
The following code causes Chibi to allocate more and more memory:
(do ((i 0 (+ i 1)))
(#f)
(symbol->string (string->symbol (number->string i)))
(when (zero? (modulo i 10000))
(display (gc))
(newline)))
Aren't the generated interned symbols garbage-collected?
Yes, the symbol table implementation predates weak references. We can probably fix this now easily.
A slight complication may arise when symbols are used as weak keys (for example, in ephemerons). As symbols can always be reforged using string->symbol a symbol weak key may never be invalidated even if the interned symbol is being garbage collected.