[erlang-questions] demonitor

Raimo Niskanen raimo+erlang-questions@REDACTED
Fri Aug 22 14:47:09 CEST 2008


On Fri, Aug 22, 2008 at 01:56:55PM +0200, Claes Wikstrom wrote:
> 
> I just recently discovered some bugs in the ssh application.
> basically it's a code like in gen.erl
> 
>              erlang:demonitor(Mref),
>              receive
>                  {'DOWN', Mref, _, _, _} ->
>                      {ok, Reply}
>              after 0 ->
>                      {ok, Reply}
>              end;
> 

You want
	erlang:demonitor(Mref, [flush])

> 
> 
> The flushing wasn't there in the ssh app, and thus the DOWN messages
> got accumulated and there was a memory leak. (I posted to erlang-patches)
> 
> Anyway, here is my question.
> 
> Don't you _always_ want to do that flushing after demonitor. And if
> so, shouldn't the BIF do that. I bet there is whole lot of code
> out there which doesn't properly do the flush.

In that case _always_ use erlang:demonitor(Mref, [flush]).

We could not change the behaviour of erlang:demonitor/1;
backwards compatibility...

> 
> /klacke
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list