[erlang-questions] Actor garbage collection

Robert Virding <>
Thu Nov 4 15:19:31 CET 2010


Hi,

No, processes are never removed until they are explicitly killed. Even if there is no reference to it anywhere there are still ways to get hold of it, for example by calling processes/0 or list_to_pid/1 (very naughty). Also in a distributed node then other nodes may contain references to a process even if there are no local references.

There are some things in Erlang which are not collected, for example pids, ets tables and modules.

Robert

----- "Tony Hannan" <> wrote:

> Hello,
> 
> Does an orphaned waiting process get garbage collected? By orphaned I
> mean
> no one references it (no one has its pid) so it will never receive
> anymore
> messages. By waiting I mean it is waiting for a message inside a
> receive.
> For example,
> 
>     Wait = fun() -> receive _ -> 0 end end.
>     spawn(Wait).
> 
> Will that spawned process live and wait forever even though we did
> not
> capture its pid and thus can't send messages to it, or will it be
> garbage
> collected eventually?
> 
> Thanks,
> Tony


More information about the erlang-questions mailing list