On Mon, Mar 30, 2009 at 2:09 AM, I=F1aki Baz Castillo <ibc / aliax.net> wrote=
:

> Hi, in Ruby 1.8 there is an issue when adding more and more Symbols
> since they remain in memory and are never removed.
>
> I'm doing a server in Ruby that receives messages with headers (From,
> To, Subject, X-Custom-Header-1...) and after parsing I store the
> headers in a hash using symbols as keys:
>
>  headers =3D {
>    :from =3D> "alice / aaa.com",
>    :to =3D> "bob / bbb.com",
>    :"x-custom-header-1" =3D> "Hi there"
>  }
>
> I could use strings as keys instead of symbols, but I've checked that
> getting a Hash entry is ~25% faster using Symbols.
>

Use symbols... FOR SPEED!  Unfortunately that speed comes at a price... you
really want to globally internalize arbitrary input?  Symbols are
effectively a freeform enumeration... the reason you're running into
problems is because you're trying to enumerate arbitrary inputs.

Is this really an important bottleneck in your application?  If not, use
strings and move on.

--=20
Tony Arcieri
medioh.com