mental / rydia.net wrote: > ... > Symbols are never garbage-collected, so you should not use them for > situations where you could have an unbounded number of unique > symbol values. > Is the non-garbage-collection of symbols just a matter of the current garbage collector, or something inherent in the ruby language? It seems Lisps typically do garbage collect symbols (*note 1), and since Java 1.2, "interned" strings (*2) are also garbage collected; and java symbols like method names area cleaned up through their class unloaders. I think the answer to this is pretty relevant to the guys in this thread who were thinking of using large numbers of dynamically generated symbols. If Yarv2.0 will garbage collect symbols, I think the answer becomes "yeah, use symbols for that if your immediate memory needs can handle it"; but if there's some fundamental reason why symbols won't be collected down the road, I think the answer becomes the much uglier "emulate your own symbols with a map of weak references". Notes: *1 http://community.schemewiki.org/?scheme-faq-language "Most Schemes do perform garbage-collection of symbols, since otherwise programs using string->symbol to dynamically create symbols would consume ever increasing amounts of memory even if the created symbols are no longer being used." *2 http://mindprod.com/jgloss/interned.html "In the early JDKs, any string you interned could never be garbage collected because the JVM had to keep a reference to in its Hashtable so it could check each incoming string to see if it already had it in the pool. With JDK 1.2 came weak references. Now unused interned strings will be garbage collected."