Erlang/Windows stabilty - a newbie question.

Ulf Wiger ulf@REDACTED
Sun Mar 26 21:34:46 CEST 2006

Den 2006-03-26 19:53:46 skrev kaslist <kaslist@REDACTED>:

> Hi,
> This is my first post to the the list - I've been coding for about  
> twenty-five years... but currently I'm an Erlang newbie :) At the  
> moment, I'm having a bit of a problem with program stability using  
> Erlang and I wondered if anyone here could help.  I'm using R10B-10 on  
> WinXP (2GHz/1GbRAM) and I've narrowed the issue to the following code  
> which I've wrapped in a simple module to demonstrate:


> Every time it crashes.  Thus my question is... am I doing something  
> intrinsically dumb/non-erlang here.... or is it a bug?  I know Erlang  
> doesn't pretend to be an efficient sequential processor... but I didn't  
> expect this.

I think you've stumbled upon one of Erlang's small quirks, described
in chapter 5.14 of the Erlang FAQ:

  "Normal data in Erlang is put on the process heap, which is garbage  
collected. Large binaries, on the other hand, are reference counted. This  
has two interesting consequences. Firstly, binaries don't count towards a  
process' memory use. Secondly, a lot of memory can be allocated in  
binaries without causing a process' heap to grow much. If the heap doesn't  
grow, it's likely that there won't be a garbage collection, which may  
cause binaries to hang around longer than expected. A strategically-placed  
call to erlang:garbage_collect() will help."

It isn't immediately obvious, as the string:tokens/2 call should
generate lots of garbage, which should also take care of the
binaries. Still, if you'd throw in a call to
erlang:garbage_collect() every once in a while, your system will
probably stay up.

In a live system, you'd want to consider spawning a process
to do the work and then die.

Ulf W
Ulf Wiger

More information about the erlang-questions mailing list