chibi-scheme icon indicating copy to clipboard operation
chibi-scheme copied to clipboard

Garbage collection of symbols

Open mnieper opened this issue 7 years ago • 2 comments

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?

mnieper avatar Oct 05 '18 06:10 mnieper

Yes, the symbol table implementation predates weak references. We can probably fix this now easily.

ashinn avatar Oct 05 '18 12:10 ashinn

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.

mnieper avatar Oct 05 '18 12:10 mnieper