[erlang-questions] Reference counting instead of GC?

Alpár Jüttner alpar@REDACTED
Thu Jul 3 14:16:40 CEST 2008


Hi,

Did anyone consider replacing the garbage collection with reference
counting in the Erlang emulator? How difficult would it be to do?

Probably, it isn't worth changing in general, but reference counting has
some advantages which are important in some special use cases:

      * Per process memory pools is not necessary. 
      * Message passing (of large data) will be more efficient as
        messages don't have to be physically copied. 
      * There is no need for garbage collection.  GC is for example a
        major pitfall in hard real time systems (see e.g.
        http://www.erlang.se/workshop/2007/proceedings/05nicosi.pdf )

Here are the drawbacks I can see now:

      * Higher memory overhead. 
              * However the memory is less fragmented, so we get back
                something in return.
      * It is said to be slower. I'm not absolutely convinced about it
        though. 
      * In general, the highest problem with reference counting is that
        in case of cross/circular referencing, dead objects will be left
        in the memory. However, this cannot happen in Erlang due to the
        immutability of the data.

Regards,
Alpar





More information about the erlang-questions mailing list