[erlang-questions] garbage collection: when?

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Sun Jun 5 17:23:24 CEST 2011

On Sun, Jun 5, 2011 at 03:24, Anthony Molinaro
<anthonym@REDACTED> wrote:

> * Use ETS to share data common to your processes.
> I thought data was copied out of ETS each time you access it (unless it
> references a constant or large binary I assume at which point you probably
> get a pointer).  So while you are sharing you're sharing copies if two
> processes both access an entry, and not a pointer to the data, correct?

This is correct. The data will be copied to the process. But if you
let go of the data it will be garbage collected on the next
collection. Note that 'free()' is essentially at no cost in a
two-space collector which is the default for a process. What you can't
do is to share large amounts of data that way since the copy will then
get too expensive.


More information about the erlang-questions mailing list