[erlang-questions] Question about TCP connection and drv_binary memory allocation

叶少波 ye02@REDACTED
Fri Dec 8 05:07:01 CET 2017


Hi erlang experts,


I did a testing about tcp connection.
The scenario is simple:
1) start two erlang nodes (let us say "node C" and "node S") with flag "+Mim true" to enable the instrument;
2) on "node S" I start a TCP server which accepts connections;
3) on "node C" I spawn 10000 processes to connect to "node S"; all the connections were successful;
4) I use instrument to lookat the "drv_binary" and "binary" memory status, I found on "node S", there was a 419461 bytes drv_binary item
   corresponded to per TCP connection; but there was NOT a same drv_binary item on "node C".   The total memory usage on "node S"
  is 419461 * 10000, about 4G, too huge.


 My question is: who allocated the 419461 drv_binary memory?


This is the tcp options on "node S" I used:

-define(TCP_OPTS, [

    binary,

    {backlog, 256},

    {packet, 0},

    {active, false},

    {reuseaddr, true},

    {nodelay, false},

    {delay_send, true},

    {keepalive, true},

    {send_timeout, 60000},

    {exit_on_close, true}

]).

  
This is the memory status that I use instrument:memory_data/0 and  instrument:descr/1 to lookat:
[ .......
  .......
  ........ 
{drv_binary,2737203904,419461,undefined},
 {drv_binary,2743914464,419461,undefined},
 {drv_binary,2746012024,419461,undefined},
 {drv_binary,2746851048,419461,undefined},
 {drv_binary,2748109584,419461,undefined},
 {drv_binary,2751883560,419461,undefined},
 {drv_binary,2753561608,419461,undefined},
 {drv_binary,2753981120,419461,undefined},
 {drv_binary,2760691680,419461,undefined},
 {drv_binary,2761111192,419461,undefined},
 {drv_binary,2762789240,419461,undefined},
 {drv_binary,2764047776,419461,undefined},
 {drv_binary,2778307920,419461,undefined},
 {drv_binary,2781244504,419461,undefined},
 {drv_binary,2787955064,419461,undefined},
 {drv_binary,2789633112,419461,undefined},
 {drv_binary,2790052624,419461,undefined},
 {drv_binary,2796343672,419461,undefined},
 {drv_binary,2809764792,419461,undefined},
 {drv_binary,2810603816,419461,undefined},
 {drv_binary,2813540400,419461,undefined}]


Thanks very much.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20171208/5ac83153/attachment.htm>


More information about the erlang-questions mailing list