[erlang-questions] Where are the binaries in message queue but not part of process_info(Pid, binary) ?

Bekes, Andras G Andras.Bekes@REDACTED
Tue Oct 17 16:00:41 CEST 2017

Hi All,

While investigating a system that transfers lots of refc binaries, I tried measuring the amount of data in the message queue of a process. I noticed that the binaries in the message queue are not always included in the result of process_info(Pid, binary).
In particular, when observing the binaries, I see time intervals when each of the new messages appear in the binary list, and time intervals when the binary list stays the same regardless of new messages in the queue.

I made a simple module that demonstrates the phenomenon. The output looks like:

Msgs sent: 0 Msgs in queue: 0 Binaries of receiver: 0
Msgs sent: 1 Msgs in queue: 1 Binaries of receiver: 1
Msgs sent: 2 Msgs in queue: 2 Binaries of receiver: 2
[...goes well up to 36...]
Msgs sent: 36 Msgs in queue: 36 Binaries of receiver: 36
[then binary count stays 36, for thousands of messages, and suddenly starts counting again ! ]

Looks like if there are some magic limits at 36 (sometimes 33), 256, 4781, 12518 and 20255 messages/binaries and so far I was unable to find any logic in which limit takes effect.

I am aware that this feature of process_info is not meant for production use ("can be changed or removed without prior notice."), but this misleading behavior is maybe worse than not having it.

May I kindly ask for an explanation of what I observe?


Andras G. Bekes

My test module:



   io:format("Testing sleeper...\n",[]),
   PID = spawn_link(fun sleeper/0),
   sender(PID,0,10000,x). % no reason to test further, binary count never goes above 36

   io:format("Testing receiver...\n",[]),
   PID = spawn_link(fun receiver/0),
   sender(PID,0,100000,x). % worth testing big numbers


   receive _ -> ok end,

sender(_,N,N,_)-> io:format("Sent ~p messages.",[N]);

   [{message_queue_len,MsgQLen}, {binary,BinaryInfoList}] =

   BinLen = length(BinaryInfoList),
   case BinLen of
      LastBinLen -> io:format(".",[]);
      _ -> io:format("Msgs sent: ~p Msgs in queue: ~p Binaries of receiver: ~p \n",[N,MsgQLen,BinLen])

   RefcBinary = binary:copy(<<N:32>>,1000),
   PID ! RefcBinary,



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20171017/1000f971/attachment.htm>

More information about the erlang-questions mailing list