Atom pollution

Joe Armstrong (AL/EAB) joe.armstrong@REDACTED
Tue Feb 22 11:33:52 CET 2005


> I've read that atoms are not garbage collected. But suppose I use the 
> following code:
> 
> a(String) -> b(list_to_atom(String)).
> 
> b(hello) -> ...
> b(ciao) -> ...
> b(bonjour) -> ...
> 
> 
> String can be "hello", "ciao" or "bonjour".
> 
> What happens each time a/1 is called? Is a new atom created 
> each time or 
> there is a sort of "atom hash"?

There is an atom hash table - so a new atom is created the first time
you call list-to_atom, thereafter a pointer to the atom is returned.

Note that the atom hash table is finite and is not garbage collected.

Although it is finite it is "pretty big" (TM) so this fact 
might not worry you.

<<aside>>
How big is "pretty big" (Björn? - anybody????)

<</aside>>

/Joe
 


> 
> Regards,
> --Corrado
> 
> -- 
> ======================================================
> Eng. Corrado Santoro, Ph.D.
> 
> University of Catania - Engineering Faculty
> Department of Computer Science and
> Telecommunications Engineering
> Viale A. Doria, 6 - 95125 CATANIA (ITALY)
> 
> Tel: +39 095 7382380           Fax: +39 095 7382397
>       +39 095 7382365
>       +39 095 7382364
> 
> EMail: csanto@REDACTED
> Personal Home Page:
>              http://www.diit.unict.it/users/csanto
> 
> NUXI Home Page:
>              http://nuxi.iit.unict.it
> ======================================================
> 
> 



More information about the erlang-questions mailing list