W3NDO

W3NDO

I went back to building on ruby during an interview and I was asked to explain symbols. It got me thinking about ruby symbols and elixir atoms. One of the big differences between ruby symbols and elixir atoms is that atoms aren’t garbage collected and thus there is a possibility of atom exhaustion.

I went further and learned that in the older ruby days(ruby < 2.2) there was also a possibility of symbol exhaustion(https://stackoverflow.com/questions/16621073/when-to-use-symbols-instead-of-strings-in-ruby).

So my question is still why aren’t atoms GC’d. My first thought is because module names and some keywords like false, true and nil are internally represented as atoms it is better to have them in memory the whole time. But that doesn’t seem correct to me.

And is there a way to manually free an atom once it has been declared and you are sure it is no longer being used?

Showing Posts 1 to 4

mudasobwa

mudasobwa

Creator of Cure

There is no such thing as “Elixir atom,” it’s rather “Erlang atom.”

There is a very descriptive answer to your question by one of Erlnag core team members.

W3NDO

W3NDO OP

Ah my mistake, erlang atoms. It is an intersting read. I see that the discussion is pretty old. Interesting to see that even the Prolog community had to make a choice about GC:ing atoms.

mudasobwa

mudasobwa

Creator of Cure

Well, technically, counters and atomics might be taken as a proof of concept. Making atom table mutable is surely possible nowadays without much hussle and without a huge performance penalty.

The question is whether it’s really needed.

rvirding

rvirding

Creator of Erlang

It is the GC which is the problem. If you want to garbage collect atoms then you need to do global GC which would either creates breaks in execution, which is totally unacceptable, or be very costly in memory or execution. @garazdawi in his answer goes through this.

— All posts loaded —

Where Next? Top

Trending in Thoughts On... Top

code-anth
Hello. I have benchmarked the JSON module ( JSON — Elixir v1.20.4 ) against a few libraries, including Erlang’s :jiffy. I’ve noticed a pa...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews