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

preciz
I had a lot of back and forth with Codex CLI &amp; GPT 5.6 Sol to use a SWAR optimization for URI.encode_www_form/1. I now have a versio...
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
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
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
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews