News for hackers. Stuff that matters.
Re:Erlang is a hoarder by ams6110 on Monday February 13, 2012 @09:35PM (#3588372)
Might this be considered a symptom of an architecture problem? I'm far from an Erlang expert but my understanding is that processes generally should be short lived, except for supervisors, which should only supervise. Instead of having a single long-lived process handling a lot of large binaries would a better design be to have separate processes handling each binary?
Re:Erlang is a hoarder by mononcqc on Monday February 13, 2012 @10:54PM (#3588530)
It depends. Some state needs to live, some needs to go. Long-lived processes should ideally do few state manipulations, or be easy to replace (so they store less state). Risky or frequent operations should be done far down in the supervision tree.

The processes with complex state, things that can't be lost, might tend to be long-lived. In these cases, they should either only do very simple operations, or be isolated from the operations on that state.

These processes will generally live higher up in the supervision tree structure and delegate the risky work to processes lower in the hierarchy; these short-lived workers will thus have their impact limited, but will also have their state known before some unit of work, a bit like an invariant. If the short-lived worker dies, then restarting it with its short-lived state is a cheap operation.

Restarting the long-lived process is a difficult thing because the state might be a) possible to re-compute, but complex to do so, or b) bound to events that cannot be repeated, and can't be lost.

Re:Erlang is a hoarder by skeltoac on Tuesday February 14, 2012 @09:37AM (#3590116)
In my case the processes needing gc are streaming TCP sockets. Their module is just a loop function which receives a binary and sends it to the client then does a tail call. So there should be no reason for the process to die. They have been running indefinitely except when the system ran into swap.