[erlang-questions] Erlang Memory Question

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Wed Sep 24 15:53:42 CEST 2014


On Wed, Sep 24, 2014 at 3:13 AM, Eranga Udesh <eranga.erl@REDACTED> wrote:

> However my suggestion is to, instead of doing a full sweep by the garbage
> collector (GC) to identify data going out of scope and reclaim, can the
> program (or rather I) deliberately say I (the calling process) is finished
> using the said data, so the GC may free that part.


You probably want to read the paper "A unified theory of Garbage
collection", Baker et.al[0]. What you are proposing is certainly possible.
You can identify data which is dead after you leave a scope and quickly
reclaim such data. Very simple data already has this property and goes onto
the Y stack in he VM. It has to be weighed against a number of factors
though. It is not a priori clear it would provide a much better space
profile of the program. The Erlang GC is generational to avoid storing data
which is short-lived in size, so usually it is able to take care of dead
data quite efficiently.

The paper describes the duality between quick release of data weighed
against the advantage of batching up garbage collection in larger chunks.
Good GCs tend to gravitate toward the dual point. So a collector relying on
reference counting has to adapt itself as to not pause the system when
freeing up a large structure. And systems relying on batch collection gains
what you propose to free memory faster for certain known corner cases.

That said, I am interested in your use case, because I have never really
hit Erlangs GC as a limiting factor. Maybe because I'm concious about how a
GC works and tries to pet it nicely :)


[0] http://www.cs.virginia.edu/~cs415/reading/bacon-garbage.pdf


-- 
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140924/cfcc51ff/attachment.htm>


More information about the erlang-questions mailing list