[erlang-questions] process_info message_queue_len
Fri Jun 1 16:23:44 CEST 2007
> I want to know which of the processes in my system is taking long to handle
> messages. I tried to use erlang:process_info(PID) to get the
> message_queue_len. The problem is that it always returns 0.
> As an example, I built the following function to test it.
> F=fun() -> receive xx -> io:format("done~n") end end.
> This gives me a message_queue_len of 0. Am I missing something?
The example works fine if the code is compiled, but in the Erlang
shell it does not give the expected result.
This is due to the way the shell (or rather: erl_eval) evaluates
'receive': the messages are removed from the message queue and kept in
a list until some receive clause matches.
Hans Bolinder, Erlang/OTP team
More information about the erlang-questions