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

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

问题描述

据说原子不是垃圾收集的。一旦你创建了一个原子,它仍然在原子表中,这可能会在一天结束时导致内存泄漏!



我对Erlang来说相当陌生,我的问题是:原子如何被垃圾收集?如果不可能,如何尽量减少这种影响?

解决方案

除非您动态创建原子,否则原子不是问题。如果你这样做了,那么你正在赶路Erlang系统。

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



如果您对Erlang垃圾收集感兴趣,请阅读Joe撰写的这篇论文阿姆斯特朗: One Pass实时世代标记清扫垃圾收集(1995年)



请牢记: 不要动态创建Atoms!

有时您可能需要动态创建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!

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?

解决方案

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.

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

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

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天全站免登陆