[erlang-questions] gen_server message queue length increasing

Magnus Klaar <>
Fri Nov 4 15:22:47 CET 2011


Hi!

@Wang

It is not ok to let a gen_server delete itself because it is not guaranteed
to delete the reference associated with it from the shared table. This
approach will leak memory unless the child processes don't exit under ideal
conditions.

@Zvi

when you both link and monitor the child process you are doubling the
amount of work your server needs to keep up with, since you are already
linked you can skip monitoring.

There is also one possible issue with your server which is that you are
starting the child processes directly from the same server receiving the
EXIT and DOWN messages. In the process info you included you can see that
the current function is proc_lib:sync_wait, this call happens to be
inefficient on processes with large inboxes, it'll likely turn out to be
much more of a bottleneck than the ETS calls in delete_by_pid.

MVH Magnus

On Fri, Nov 4, 2011 at 3:36 AM, Wang Wei <> wrote:

> Hi, Is it ok to let spawned gen_servers delete themselves in ETS table
> when they terminated? If you spawn and destroy too fast that will a lock
> condition in the main gen_server.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111104/8d5918e8/attachment.html>


More information about the erlang-questions mailing list