From: Sigurd Date: 2012-02-17T19:17:22+09:00 Subject: Re: Symbol garbage collection On Feb 17, 2012, at 11:58 AM, Ronnie Collinson wrote: > But two equal strings can be two separate objects ("a" == "a" could be > false), It always be true. In a sense of how they are stored - yes, they can be stored in different places, but in terms of ruby code that strings always would be equal. Also string === method is also comparing strings by their content, not by are they the same object a = "a" b = "b" a.object_id => 2181707380 b.object_id => 2181676040 a === b => true a == b => true > two equal symbols will be (including your example, all > variables are still pointing to your new/hacked symbol ) the same > object, its not how the data is stored, saving memory but how it can > be a single instance for the lifetime of the process. > > If space is the only gain, then gcing symbols would remove some other > nice properties such as single instance, Id rather pay a small bit of > space for nice properties. > > When/If the symbols were in a separate area in memory to the gc's > heap, then the gc would never waste time looking at the symbols, would > that make a measurable/worthwhile improvement to the gc speed? >