<div>Hi experts,</div><div><br></div><div>I wrote a server that accepts TCP connections. The listen socket starts with the options below:</div><div><div>  -define(TCP_OPTS, [</div><div>    binary,</div><div>    {backlog, 256},</div><div>    {packet, 0},</div><div>    {active, false},</div><div>    {reuseaddr, true},</div><div>    {nodelay, false},</div><div>    {delay_send, true},</div><div>    {keepalive, true},</div><div>    {send_timeout, 60000},</div><div>    {exit_on_close, true}</div><div>]).</div></div><div>On the server node every new connection will spawn a new gen_server to handle it.</div><div><br></div><div>And  then I spawn 5000 gen_servers on another erlang node(I call it Client node), every gen_server will connect to the server via TCP.</div><div><br></div><div>It is a really simple case.</div><div><br></div><div>After setup 5000 connections I found the binary memory on server node was used up to 17G;</div><div>and the binary memory on the Client node was 42M.  It is a huge difference.</div><div><br></div><div>Then I rebooted  the erlang node with "+Mim true"  and "+Mis true"; after re-setup 5000 connections again, I used </div><div>instrument:memory_status(types) to check the memory status, I found the dry_binary allocated 17G memory:</div><div><div>[{drv_binary,[{sizes,1844114912,1844116842,1844116842},</div><div>              {blocks,5227,5724,5724}]},</div><div> {code,[{sizes,39944997,39955374,39955374},</div><div>        {blocks,1321,1321,1321}]},</div><div> {heap,[{sizes,28000216,78942872,78942872},</div><div>        {blocks,5263,5267,5267}]},</div><div> {old_heap,[{sizes,21132056,72481264,72481264},</div><div>            {blocks,2940,4736,4736}]},</div><div> {binary,[{sizes,17908918,21738516,21738516},</div><div>          {blocks,25087,35039,35039}]},</div><div> {proc_tab,[{sizes,12582975,12582975,12582975},</div><div>            {blocks,1,1,1}]},</div><div> {export_entry,[{sizes,7108992,7108992,7108992},</div><div>                {blocks,40392,40392,40392}]},</div><div> {db_term,[{sizes,6930120,6930200,6930200},</div><div>           {blocks,13149,13150,13150}]},</div><div> {port_tab,[{sizes,6291519,6291519,6291519},{blocks,1,1,1}]},</div><div> {proc,[{sizes,4211200,4212800,4212800},</div><div>        {blocks,5264,5266,5266}]},</div><div> {port,[{sizes,3392108,3393432,3393432},</div><div>        {blocks,5101,5103,5103}]},</div></div><div>.......</div><div><br></div><div>My question is : How can I decrease the drv_binary memory? What parameter caused the server used so much memory?</div><div><br></div><div>Thanks,</div><div>BRs/Michael</div><div><br></div><div><br></div><div><br></div><div><includetail><!--<![endif]--></includetail></div>