[erlang-questions] how are erlang process lightweight?

Sean Hinde sean.hinde@REDACTED
Tue Oct 3 13:58:05 CEST 2006


On 3 Oct 2006, at 12:25, Ben Dougall wrote:

>
> So that seems to be the thing, so far as memory footprint goes:  
> threads
> have a stack and that stack is, as usual, made up or an indefinite
> number of frames -- potentially many/infinite -- grows per new  
> function
> call. Whereas Erlang processes are tied very tightly (one to one) to
> functions, and a function's memory usage amount to one frame of a
> stack. So an Erlang process is limited to a frame of a stack.

This is where you are going wrong. An erlang function is only related  
to a process in the sense that processes evaluate functions. Each  
process has its own stack that can grow/shrink as much as it needs.

It is not nearly as different to pthreads as you describe. The  
efficiency gains of Erlang are *only* those of being able to optimise  
process switching and do custom memory management. Erlang processes  
are actually more akin to UNIX processes as they do not share state.  
Think of them as exactly like UNIX processes with much less overhead  
and much nicer message passing.

Having the flexibility to implement language specific memory  
management and process switching with custom message passing are big  
wins until UNIX implements the same things directly. I suspect that  
is not likely to happen soon.

Sean






More information about the erlang-questions mailing list