Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Erlang atoms can be garbage collected

It is said that atoms are not garbage collected. Once you’ve created an atom, it remains in the atom table, which might cause memory leakage at the end of the day!

I'm fairly new to Erlang, and my question is: How the atoms can be garbage collected? And if not possible, how to minimize that effect?

like image 987
securecurve Avatar asked Dec 11 '13 11:12

securecurve


1 Answers

Atoms aren't issue unless you are creating them dynamically. If you did that, then you are on your way to crash an Erlang system.

How to create Atoms dynamically? For example calling list_to_atom function inside a loop.

If you are interested in Erlang garbage collection, then read this paper by Joe Armstrong: One Pass Real-Time Generational Mark-Sweep Garbage Collection (1995).

Always keep in mind: Don't create Atoms dynamically!
Well sometimes you might need to create an Atom dynamically BUT don't over use it!

like image 106
Chiron Avatar answered Sep 28 '22 05:09

Chiron