[erlang-questions] question about binary memory

叶少波 <>
Mon Sep 19 16:57:19 CEST 2016


My question is about the binary memory usage.
I implemented a server which accepts Tcp connection. All the Tcp connections use binary options.

Before I set up 10000 Tcp connections to my server, the memory usage is as below:
()1> erlang:memory().

after I set up 10000 Tcp connections, every connection is hold by one gen_server; the memory usage is as below:

And I check the binary hold by all the processes on the node with the command below:
List = [begin {binary, L} = erlang:process_info(P, binary), {P, (lists:foldl(fun({_, I, _}, Acc) -> Acc + I end, 0, L))} end || P <- processes() -- [self()]], lists:foldl(fun({_, A}, Acc) -> A + Acc end, 0, List). 
the result is 23113860.  It is much less than the value 2437117184 reported by erlang:memory().

My question is :
why does the VM allocate so much memory for binary?
Does the Tcp ports allocate their send/recv buffer on binary heap?
Is there any way I can see what are in the binary heap?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160919/5c85097d/attachment.html>

More information about the erlang-questions mailing list