[erlang-questions] Increase in heap size
Angel Alvarez
clist@REDACTED
Fri Dec 18 22:12:21 CET 2009
El Viernes, 18 de Diciembre de 2009 maruthavanan s escribió:
>
> Hi,
>
> I have a old code written by some one else, this is not a OTP,
>
> start()->
> receive
> {data,Data}->
> process_data(Data);
> end,
> start().
>
> After I run my system this process heap size is increase to enourmous extent with bigger values of reductions.
>
> I could not understand reductions. Is this not a good programing practice? What would be the right way? what should I do to optimize this?
>
> Please help.
>
> Regards,
> Marutha
>
i seems there is no return values from process_data(Data) so you are using side-efects
to alter state?
In that case a spawn(?MODULE,process_data,[Data]) will free your processs to receive more mesages
while process_data is running on another process (and will free memory when this new process finishes).
While is known that erlang can suffer from massive amounts of messages in a mailbox combined with selective receive
what is considered a bad practice is to send messages asyncronously from external sources like sockets and in general
whatever source of message you use is preferable to have some degree of flow control.
using {active, once} on a listening socket can mitigate the problem (look on the archives for many examples on this).
Joe has a simple tcp example on his pages (i cant remember the URL)
anyone has suitable examples at hand?
/Angel
--
Agua para todo? No, Agua para Todos.
->>-----------------------------------------------
Clist UAH a.k.a Angel
---------------------------------[www.uah.es]-<<--
Warning: Microsoft_bribery.ISO contains OOXML code.
More information about the erlang-questions
mailing list