Erlang 原子如何被垃圾回收 [英] How Erlang atoms can be garbage collected

查看:41
本文介绍了Erlang 原子如何被垃圾回收的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据说原子不会被垃圾收集.一旦你创建了一个 atom,它就会保留在 atom 表中,这最终可能会导致内存泄漏!

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!

我是 Erlang 的新手,我的问题是:如何对原子进行垃圾收集?如果不可能,如何最小化这种影响?

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?

推荐答案

原子不是问题,除非您动态创建它们.如果你这样做了,那么你正在使 Erlang 系统崩溃.

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.

如何动态创建原子?例如在循环中调用 list_to_atom 函数.

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

如果您对 Erlang 垃圾收集感兴趣,请阅读 Joe Armstrong 的这篇论文:一次性实时分代标记-扫描垃圾收集 (1995).

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).

始终牢记:不要动态创建 Atom!
好吧,有时您可能需要动态创建 Atom,但不要过度使用它!

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!

这篇关于Erlang 原子如何被垃圾回收的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆