[erlang-questions] Dynamically generated atoms get reused if they are the same?
Mon Nov 5 23:37:05 CET 2007
It is only an increasing number of different atoms which can cause the
VM to allocate more and more memory and sooner or later run out of
So if you use list_to_atom on a limited set of values you are safe.
There is also the function list_to_existing_atom which let you convert
a string to an atom only if the atom already exist.
If for example the atoms are used as literals in the code in some module and
this module is loaded then the atoms already exist when list_to_atom
of the atoms used in the module is called.
/Kenneth Erlang/OTP team at Ericsson
On 11/5/07, <> wrote:
> 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
> erlang-questions mailing list
More information about the erlang-questions