<div dir="ltr">It is complex question. You should locate who hold the memory first :)<div>Below codes might help you to locate the process / ets</div><div><br></div><div>```</div><div>applications_memory() -><br> try application:which_applications() of<br> Apps -><br> lists:map(<br> fun({AppName, _, _}) -><br> Mem = application_memory(AppName),<br> {AppName, Mem}<br> end, Apps)<br> catch<br> _:Exception -><br> error_logger:error_msg("[~p] get application memory failed ~p", [?MODULE, Exception]),<br> undefined<br> end.<br><br>application_memory(App) -><br> case application_controller:get_master(App) of<br> Master when is_pid(Master) -><br> {Root, Name} = application_master:get_child(Master),<br> {Memory, Children} = memory_info(Root),<br> {Name, Memory div 1000000, Children};<br> _ -><br> undefined<br> end.<br><br>memory_info(Sup) -><br> Infos = supervisor:which_children(Sup),<br> {M, E, ES} =<br> lists:foldl(<br> fun({Name, PId, Type, _}, {Total, Memories, MemorySets}) -><br> case Type of<br> worker -><br> {memory, Memory} = process_info(PId, memory),<br> NTotal = Total + Memory,<br> case Name of<br> undefined -><br> NMemorySets =<br> case gb_sets:size(MemorySets) of<br> Size when Size > 10 -><br> {_, NSets} =<br> gb_sets:take_smallest(MemorySets),<br> NSets;<br> _ -><br> MemorySets<br> end,<br> NNMemorySets = gb_sets:insert(<br> {undefined, Memory, PId}, NMemorySets),<br> {NTotal, Memories, NNMemorySets};<br> Name -><br> {NTotal, [{Name, Memory, PId}|Memories], MemorySets}<br> end;<br> supervisor -><br> {Memory, Each} = memory_info(PId),<br> NTotal = Total + Memory,<br><br> {NTotal, [{Name, {Memory, Each}, PId}|Memories], MemorySets}<br> end<br> end, {0, [], gb_sets:new()}, Infos),<br> NE =<br> case E of<br> [] -><br> gb_sets:to_list(ES);<br> _ -><br> E<br> end,<br> NNE = lists:map(<br> fun({N, Mem, PId}) -><br> case Mem of<br> Mem when is_integer(Mem) -><br> {N, Mem div 1000000, undefined, PId};<br> {T, RestEach} -><br> {N, T div 1000000, PId, RestEach}<br> end<br> end, NE),<br> NNNE = lists:reverse(lists:keysort(3, NNE)),<br> {M, NNNE}.<br><br>ets_memory() -><br> All = ets:all(),<br> AllMems = lists:map(<br> fun(Ets) -><br> Mem = ets:info(Ets, memory),<br> {Ets, Mem}<br> end, All),<br> Mems =<br> lists:sort(<br> fun({_, M1}, {_, M2}) -><br> M1 > M2<br> end, AllMems),<br> Sum = lists:sum(lists:map(fun({_, Mem}) -> Mem end, AllMems)),<br> {Sum, Mems}.<br></div><div>```</div><div><div>Also I recommend <a href="https://github.com/ferd/recon/blob/master/src/recon_alloc.erl">https://github.com/ferd/recon/blob/master/src/recon_alloc.erl</a> .</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Sep 28, 2019 at 10:03 PM <<a href="mailto:buday.gergely@uni-eszterhazy.hu">buday.gergely@uni-eszterhazy.hu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div dir="ltr"><div style="color:rgb(33,33,33);background-color:rgb(255,255,255);text-align:left" dir="ltr">Hi there,</div><div style="color:rgb(33,33,33);background-color:rgb(255,255,255);text-align:left" dir="ltr"><br></div><div style="color:rgb(33,33,33);background-color:rgb(255,255,255);text-align:left" dir="ltr">are there experience reports on using Erlang/Elixir on systems with 200 GB of memory and more?</div><div style="color:rgb(33,33,33);background-color:rgb(255,255,255);text-align:left" dir="ltr"><br></div><div style="color:rgb(33,33,33);background-color:rgb(255,255,255);text-align:left" dir="ltr">If you have a first-hand account on that, please share it with me.</div><div style="color:rgb(33,33,33);background-color:rgb(255,255,255);text-align:left" dir="ltr"><br></div><div style="color:rgb(33,33,33);background-color:rgb(255,255,255);text-align:left" dir="ltr">My friends are doing that and said that only C++ was capable of handling that.</div><div style="color:rgb(33,33,33);background-color:rgb(255,255,255);text-align:left" dir="ltr"><br></div><div style="color:rgb(33,33,33);background-color:rgb(255,255,255);text-align:left" dir="ltr">- Gergely</div></div></div>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">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 clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Jack Tang<br><br><br><a href="http://www.linkedin.com/in/jacktang" target="_blank">http://www.linkedin.com/in/jacktang</a><br></div>