[erlang-questions] process will stack overflow after received many message?
Fri Sep 16 10:57:36 CEST 2011
On Fri, Sep 16, 2011 at 4:44 PM, Robert Raschke <rtrlists@REDACTED> wrote:
> On Fri, Sep 16, 2011 at 9:38 AM, Jovi Zhang <bookjovi@REDACTED> wrote:
>> I am a newbie of Erlang, here I have a question for receive
>> message in Erlang loop.
>> Like below Erlang code, when process receive one message, it will
>> invoke loop again,
>> then it can service like a server, receive message forever.
>> BUT is possible that process will stack overflow after receive too
>> many message? the process invoke loop again and again.
>> I saw there have many code write like this in <<Programming Erlang>>
>> loop() ->
>> hello ->
>> Other ->
>> io:format("I don't know what is this message, ~p is ~n"
> No stack overflow, due to tail call optimisation. See also
Thanks, but when I test it using escript, the result is like below,
"loop end" printed two times, it means it stacked!
[root@REDACTED Erlang]# cat jovi.erl
Pid = spawn(fun() -> loop() end),
Pid ! one,
Pid ! two,
_Any -> void
[root@REDACTED Erlang]# ./jovi.erl
More information about the erlang-questions