[erlang-questions] Erlang node memory consumption grows to 18GB in few seconds
Danil Zagoskin
z@REDACTED
Sun Apr 15 15:10:27 CEST 2018
Never use io:format("~p") on large data.
Simple solution is to limit depth: io:format("~P~n", [Data, 30])
On Sat, Apr 14, 2018 at 12:55 PM, Chaitanya Chalasani <cchalasani@REDACTED> wrote:
> Hi,
>
> I see the memory consumption of an erlang node grows exponentially and
> quickly when I was sending binary data of about 700 MB from shell to a
> simple erlang listener process and the shell process is stuck.
>
> -module(strange).
> -export([start/0, listener/0, send/1, stop/0]).
>
> start() ->
> register(?MODULE, spawn(?MODULE, listener, [])).
>
> listener() ->
> receive
> {send, Data} ->
> io:format("Received Data ~p ~n", [Data]),
> listener();
> stop ->
> io:format("Stopping listener ~n")
> end.
>
> send(Data) ->
> ?MODULE ! {send, Data}.
>
> stop() ->
> ?MODULE ! stop.
>
> $ uname -a
> Darwin Chaitanyas-MacBook-Pro.local 17.5.0 Darwin Kernel Version 17.5.0: Mon
> Mar 5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64
>
> $ erl
> Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:8:8] [ds:8:8:10]
> [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
>
> Eshell V9.3 (abort with ^G)
> 1> c(strange).
> {ok,strange}
> 2> {ok, Data} = file:read_file("centos.iso").
> {ok,<<51,237,144,144,144,144,144,144,144,144,144,144,144,
> 144,144,144,144,144,144,144,144,144,144,144,144,
> 144,144,...>>}
> 3> strange:start().
> true
> 4> strange:send(Data).
>
> BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
> (v)ersion (k)ill (D)b-tables (d)istribution
>
> The observer says -
> <0.53.0> group:server/3 93980000 17957208520 1 erlang:integer_to_list/1
>
> The Mac activity monitor shows Erlang consuming 18GB of RAM.
>
> Kindly, help me understand what is happening.
>
> /Chaitanya
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
--
Danil Zagoskin | z@REDACTED
More information about the erlang-questions
mailing list