<div dir="ltr">Hello,<div><br></div><div>You want to start the emulator with the "+Mim true +Mis true" flags and then use instrument (<a href="http://erlang.org/doc/man/instrument.html">http://erlang.org/doc/man/instrument.html</a>) to inspect what is going on. The most interesting for you should be something like:</div><div><br></div><div><font face="monospace, monospace">lists:reverse(lists:keysort(2,instrument:memory_status(types))).</font></div><div><br></div><div>For example:</div><div><br></div><div><div><font face="monospace, monospace">erl +Mis true +Mim true</font></div><div><font face="monospace, monospace">Erlang/OTP 19 [DEVELOPMENT] [erts-8.0] [source-9946a17] [64-bit] [smp:16:16] [async-threads:10] [hipe] [kernel-poll:false]</font></div><div><div><font face="monospace, monospace">1> lists:reverse(lists:keysort(2,instrument:memory_status(types))).</font></div><div><font face="monospace, monospace">[{timer_wheel,[{sizes,8391792,8391792,8391792},</font></div><div><font face="monospace, monospace">               {blocks,16,16,16}]},</font></div><div><font face="monospace, monospace"> {code,[{sizes,3463220,3463220,3469945},{blocks,84,84,84}]},</font></div><div><font face="monospace, monospace"> {proc_tab,[{sizes,3145791,3145791,3145791},{blocks,1,1,1}]},</font></div><div><font face="monospace, monospace"> {heap,[{sizes,1882920,1932208,3456120},{blocks,26,28,28}]},</font></div><div><font face="monospace, monospace"> {pre_alloc_data,[{sizes,1032303,1032303,1032303},</font></div><div><font face="monospace, monospace">                  {blocks,17,17,17}]},</font></div><div><font face="monospace, monospace"> {port_tab,[{sizes,786495,786495,786495},{blocks,1,1,1}]},</font></div><div><font face="monospace, monospace"> {old_heap,[{sizes,679872,682880,2941656},{blocks,10,11,11}]},</font></div><div><font face="monospace, monospace"> {scheduler_data,[{sizes,673141,673141,673141},</font></div><div><font face="monospace, monospace">                  {blocks,3,3,3}]},</font></div><div><font face="monospace, monospace"> {export_entry,[{sizes,462528,462528,462528},</font></div><div><font face="monospace, monospace">                {blocks,2628,2628,2628}]},</font></div><div><font face="monospace, monospace"> {literal,[{sizes,379648,379648,379648},{blocks,84,84,84}]},</font></div><div><font face="monospace, monospace"> {ethread_long_lived,[{sizes,326016,326016,326016},</font></div><div><font face="monospace, monospace">                      {blocks,283,283,283}]},</font></div><div><font face="monospace, monospace"> {atom_entry,[{sizes,304840,304840,304840},</font></div><div><font face="monospace, monospace">              {blocks,7621,7621,7621}]},</font></div><div><font face="monospace, monospace"> {beam_register,[{sizes,264544,264544,264544},</font></div><div><font face="monospace, monospace">                 {blocks,32,32,32}]},</font></div><div><font face="monospace, monospace"> {export_tab,[{sizes,162888,162888,162888},</font></div><div><font face="monospace, monospace">              {blocks,15,15,15}]},</font></div><div><font face="monospace, monospace"> {hipe_data,[{sizes,148464,148464,148464},{blocks,18,18,18}]},</font></div><div><font face="monospace, monospace"> {ethread_standard,[{sizes,133487,133487,133487},</font></div><div><font face="monospace, monospace">                    {blocks,6,6,6}]},</font></div><div><font face="monospace, monospace"> {db_term,[{sizes,119568,119568,119568},</font></div><div><font face="monospace, monospace">           {blocks,388,388,388}]},</font></div><div><font face="monospace, monospace"> {atom_tab,[{sizes,112232,112232,121472},{blocks,10,10,10}]},</font></div><div><font face="monospace, monospace"> {atom_text,[{sizes,98328,98328,98328},{blocks,3,3,3}]},</font></div><div><font face="monospace, monospace"> {db_tabs,[{sizes,82023,82023,82023},{blocks,3,3,3}]},</font></div><div><font face="monospace, monospace"> {drv_internal,[{sizes,79352,79352,79608},{blocks,4,4,19}]},</font></div><div><font face="monospace, monospace"> {db_segment,[{sizes,51744,51744,53824},{blocks,19,19,...}]},</font></div><div><font face="monospace, monospace"> {fun_entry,[{sizes,51568,51568,...},{blocks,586,...}]},</font></div><div><font face="monospace, monospace"> {drv_binary,[{sizes,47774,...},{blocks,...}]},</font></div><div><font face="monospace, monospace"> {driver_event_state,[{sizes,...},{...}]},</font></div><div><font face="monospace, monospace"> {module_tab,[{...}|...]},</font></div><div><font face="monospace, monospace"> {module_entry,[...]},</font></div><div><font face="monospace, monospace"> {proc,...},</font></div><div><font face="monospace, monospace"> {...}|...]</font></div></div><div><br></div><div>So in the above we can see that the timer wheel structures take the most memory and then code, proc tab etc etc.</div><div><br></div><div>Lukas</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 29, 2016 at 2:01 PM, Michał Muskała <span dir="ltr"><<a href="mailto:michal@muskala.eu" target="_blank">michal@muskala.eu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello everybody,<br>
<br>
This is a followup from the elixir mailing list:<br>
<a href="https://groups.google.com/forum/#!msg/elixir-lang-talk/TqIcSVkHBxs/N1nWRWW9BwAJ" rel="noreferrer" target="_blank">https://groups.google.com/forum/#!msg/elixir-lang-talk/TqIcSVkHBxs/N1nWRWW9BwAJ</a><br>
There were several issues involved in that particular problem, but one<br>
of them might be of interest to the people here as well, as it's<br>
generally erlang-related rather than tied to elixir or any package in<br>
particular.<br>
<br>
The issue comes down to unusually high memory consumption for erlang,<br>
specifically the system part from erlang:memory/0. The output below<br>
shows values when running outside docker and inside:<br>
<br>
Outside docker:<br>
erl -eval 'io:format("~w~n", [erlang:memory()]), init:stop().' -noshell<br>
[{total,15182640},{processes,3799768},{processes_used,3797720},{system,11382872},{atom,194289},{atom_used,169621},{binary,78344},{code,3868184},{ets,229416}]<br>
<br>
Inside docker's official erlang image (debian based)<br>
docker run --rm -it erlang:18-slim erl -eval 'io:format("~w~n",<br>
[erlang:memory()]), init:stop().' -noshell<br>
[{total,111303160},{processes,3799768},{processes_used,3797720},{system,107503392},{atom,194289},{atom_used,169584},{binary,595608},{code,3860673},{ets,239464}]<br>
<br>
Inside minimal alpine linux erlang image<br>
docker run --rm -it msaraiva/erlang erl -eval 'io:format("~w~n",<br>
[erlang:memory()]), init:stop().' -noshell<br>
[{total,111432888},{processes,3748312},{processes_used,3746312},{system,107684576},{atom,194289},{atom_used,169869},{binary,596568},{code,3847723},{ets,185296}]<br>
<br>
As you can see all the values except for system are very similar, with<br>
system being almost 10x as large. The issue is also consistent across<br>
different images. While outside docker a simple shell uses around<br>
15MB, inside docker it grows to 80MB.<br>
I tried to investigate the issue further using recon, and it looks<br>
like the excessive memory is allocated with ll_alloc, although I have<br>
to admit I'm out of my depth here.<br>
<br>
I'll be thankful for any help or indications where I could dig deeper.<br>
<br>
Michał.<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br></div></div></div>