Severe memory leak problem

Jeffrey Straszhiem <>
Sat Sep 23 16:12:56 CEST 2000


I think the problem is in the part here:

    . . .

            % If "\r\n" was not found, call the receive loop
            % with NewString
            true -> receive_packet(AcceptSocket, NewString)
         end,

         % If "\r\n" was found, parse the chat commands
         parse_clientcmds(AcceptSocket, NewString)

   . . .

If no newline is found, then this function calls receive_packet, from
which it never returns.  Unfortunately the compiler can't know this,
and the flow of control would otherwise fall to the parse_clientcmds
below.  This receive_packet call will not be identified as tail
recursive, and the stack frame will be left intact for its return,
which of course never happens.  You need to restructure the flow of
this function.

Warning:  I only started learning Erlang last week, so I could be
completely wrong :)

-- 
-- Jeffrey Straszheim              |  A sufficiently advanced
-- Systems Engineer, Programmer    |  regular expression is
-- http://www.shadow.net/~stimuli  |  indistinguishable from
-- stimuli AT shadow DOT net       |  magic



More information about the erlang-questions mailing list