[erlang-questions] Erlang node memory consumption grows to 18GB in few seconds
Raimo Niskanen
raimo+erlang-questions@REDACTED
Mon Apr 16 11:51:26 CEST 2018
On Sun, Apr 15, 2018 at 06:47:19PM +0530, Chaitanya Chalasani wrote:
> Thank you for that suggestion, Danil.
>
> However, removing the io:format alone didn’t solve the problem. I had to change the send function too.
>
> From:
>
> send(Data) ->
> ?MODULE ! {send, Data}.
>
> To:
>
> send(Data) ->
> ?MODULE ! {send, Data},
> ok.
>
> Does the shell also use io:format to show the function return value?
The return value from all shell commands are saved in the shell history.
/ Raimo
>
> > On 15-Apr-2018, at 18:40, Danil Zagoskin <z@REDACTED> wrote:
> >
> > 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
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
--
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions
mailing list