Stuff Goes Bad:Erlang In Anger


Review Questions

[1]. Name some of the common sources of leaks in Erlang programs.
[2]. What are the two main types of binaries in Erlang?
[3]. What could be to blame if no specific data type seems to be the source of a leak?
[4]. If you find the node died with a process having a lot of memory, what could you do to find out which one it was?
[5]. How could code itself cause a leak?
[6]. How can you find out if garbage collections are taking too long to run?

[1]. 列出Erlang程序里面常见的泄露源。
[2]. Erlang binaries有哪两种主要类型?
[3]. 如果没有数据类型看上去会造成泄露,那么还应该从哪里入手?
[4]. 如果你发现节点由于进程占用大量的内存而崩溃,你怎么找出来是哪一个进程?
[5]. 代码本身怎么引起内存泄露?
[6]. 你怎么查看到垃圾回收要花费大量的时间?

Open-ended Questions

[1]. How could you verify if a leak is caused by forgetting to kill processes, or by processes using too much memory on their own?
[2]. A process opens a 150MB log file in binary mode to go extract a piece of information from it, and then stores that information in an ETS table. After figuring out you have a binary memory leak, what should be done to minimize binary memory usage on the node?
[3]. What could you use to find out if ETS tables are growing too fast?
[4]. What steps should you go through to find out that a node is likely suffering from fragmentation? How could you disprove the idea that is could be due to a NIF or driver leaking memory?
[5]. How could you find out if a process with a large mailbox (from reading message_queue_len)?
seems to be leaking data from there, or never handling new messages?
[6]. A process with a large memory footprint seems to be rarely running garbage collections. What could explain this?
[7]. When should you alter the allocation strategies on your nodes? Should you prefer to tweak this, or the way you wrote code?

[2].一个进程使用binary 模式打开了150MB的log文件,然后找到一些有用信息,然后把这些信息都存在ETS表中。在你知晓系统存在binary 内存泄露时,你应该怎样去最小化节点上的binary 内存使用。


[1]. Using any system you know or have to maintain in Erlang (including toy systems), can you figure out if there are any binary memory leaks on there?

[1]. 看看使用的任何Erlang系统中(包括用来实验的系统),你可以诊断到binary内存泄露么?