ipinak
ipinak

Reputation: 6039

Limit in the number of atoms

In Erlang/OTP the number of atoms you can create is limited to 1,048,576, and it's not garbage collected. It is stated in the gen_server docs that atoms are not garbage collected, but I cannot find out if there is a limit.

Does Elixir have a limit as well? And if so what is it?

Upvotes: 9

Views: 2482

Answers (1)

legoscia
legoscia

Reputation: 41588

Elixir runs on the same virtual machine as Erlang, and it's thus subject to the same atom limits as Erlang.

You can check the current limit with :erlang.system_info(:atom_limit), and you can change the limit by passing the +t flag to the Erlang virtual machine, using --erl to let the flag through to Erlang:

$ elixir -e 'IO.inspect :erlang.system_info(:atom_limit)'
1048576
$ elixir --erl "+t 2000000" -e 'IO.inspect :erlang.system_info(:atom_limit)'
2000000

However, if you find yourself running out of atoms, you should probably try solving the problem in another way.

Upvotes: 18

Related Questions