[erlang-questions] Dynamically generated atoms get reused if they are the same?

nindeu <>
Mon Nov 5 23:21:24 CET 2007


According to http://www.erlang.org/doc/efficiency_guide/bif.html#6.1 atoms do not get garbage collected. Meaning if you constantly produce atoms by using list_to_atom/1 you sooner or later will run out of space for them.

Now I just wrote a small test program which indicates that as long as you produce the same atom, it will not take up additional space:

atomTest() ->
  NewAtom = list_to_atom("itsme"),
  io:format("New memory size: ~p, Atoms used: ~p~n",
    [erlang:memory(atom), erlang:memory(atom_used)]),
	register(NewAtom, self()),
	after 1000 ->

So, can anyone confirm, is it correct that dynamically generated Atoms are of no concern as long as you do not produce too many _different_ ones?

Thank you!

GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail

More information about the erlang-questions mailing list