[erlang-questions] About Garbage Collection
Jesper Louis Andersen
Thu Nov 11 14:45:02 CET 2010
2010/11/11 Ş. Volkan Erdoğan <volerdo@REDACTED>:
> It seemed like a good idea at first :)
> I just thought that , since there is no memory is shared between
> processes one can determine when a memory location is not used in a
> process conservatively by static analysis and tried to present a
> scheme for that but it turns out to be wrong.
Essentially, what region based memory management does is to make a
conservative static analysis of liveness of variables. You lace your
original language with a region language that has operations like
alloc_new_heap, alloc_in_heap, reset_heap, destroy_heap. The region
language can either be lexically scoped and functional (The
Tofte-Talpin interpretation), so imperative (the Henglein-Makholm-Niss
interpretation), so you have some freedom in choosing the language.
Static analysis now inserts operations from the region language into
the original one and then compilation will compile the region
operations as well, usually by calling a runtime function to handle
The problem is the "conservative" part, which is the reason MLton
shunted the idea. When you can't determine liveness you default to the
top-level region, which you then have to garbage collect. In other
words, you have done a lot of very hard work (lacing a region-langauge
into your system, region inference analysis, runtime modifications
etc) and the benefit is probably negligible. In MLtons case there is
so SSA-PRE pass yet, so time would be much better spent on adding that
as it could be much more beneficial.
(Obvious bias: I was somewhat loosely affiliated with the MLton
project years ago).
More information about the erlang-questions