erlang 原子数的极限

uajslkp6  于 2022-12-08  发布在  Erlang
关注(0)|答案(1)|浏览(142)

在Erlang/OTP中,你可以创建的原子数量被限制在1,048,576,并且它 * 不 * 被垃圾收集。在gen_server文档中声明原子不被垃圾收集,但是我不知道是否有限制。
Elixir 也有限制吗?如果有,是什么?

vxbzzdmp

vxbzzdmp1#

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.

相关问题