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

Bengt Kleberg <>
Tue Nov 6 08:18:02 CET 2007


yes, you are correct. only different atoms need ''different'' space.


bengt
Those were the days...
    EPO guidelines 1978: "If the contribution to the known art resides
    solely in a computer program then the subject matter is not
    patentable in whatever manner it may be presented in the claims."


On 2007-11-05 23:21,  wrote:
> Hi,
> 
> 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()),
> 	unregister(NewAtom),
> 	receive
> 	after 1000 ->
> 		atomTest()
>   end.
> 
> 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!
> 
> Regards,
> Eric



More information about the erlang-questions mailing list