Region-based memory management
  Home FAQ Contact Sign in
comp.lang.functional only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.functional Profile…
 Up
Region-based memory management         


Author: Jon Harrop
Date: Apr 4, 2008 23:55

As I understand it, MLKit is entirely region-based memory management and the
Stalin Scheme compiler uses similar techniques and this is fundamentally
different from both reference counting and mark and sweep GC.

What are the implications of this technique and how well do the compilers
perform in practice? Does it suffer from stalls or keeping values alive too
long?

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
5 Comments
Re: Region-based memory management         


Date: Apr 5, 2008 00:54

Jon Harrop ffconsultancy.com> writes:
> As I understand it, MLKit is entirely region-based memory management and the
> Stalin Scheme compiler uses similar techniques and this is fundamentally
> different from both reference counting and mark and sweep GC.

Region inference can do a lot, but I don't see how it's possible to
have no GC at all, and support typical functional programming style.
E.g., using functional maps as association tables that are "updated" a
lot by recursion, creates tons of garbage whose structure is entirely
data dependent and can't be predicted by region inference.

JHC (experimental Haskell compiler that is beating GHC at some
benchmarks) also uses region inference and is only now in the process
of getting a GC.
no comments
Re: Region-based memory management         


Date: Apr 6, 2008 11:56

On Sat, 05 Apr 2008 07:55:14 +0100, Jon Harrop ffconsultancy.com>
wrote:
>
>As I understand it, MLKit is entirely region-based memory management and the
>Stalin Scheme compiler uses similar techniques and this is fundamentally
>different from both reference counting and mark and sweep GC.
>
>What are the implications of this technique and how well do the compilers
>perform in practice? Does it suffer from stalls or keeping values alive too
>long?

Region management is "mark-release" ... essentially a stack of heaps.
The unit of reclamation is the heap - objects are (usually) allocated
as needed but all the objects within a heap are deallocated all at
once. An object's lifetime determines to which heap it is assigned
and good management depends crucially on the compiler being able to
determine close bounds on the object's lifetime.
Show full article (1.89Kb)
no comments
Re: Region-based memory management         


Author: Torben Ægidius Mogensen
Date: Apr 7, 2008 00:36

Jon Harrop ffconsultancy.com> writes:
> As I understand it, MLKit is entirely region-based memory management and the
> Stalin Scheme compiler uses similar techniques and this is fundamentally
> different from both reference counting and mark and sweep GC.

The ML-kit later got GC added on, but you can switch this off and use
regions exclusively.
> What are the implications of this technique and how well do the compilers
> perform in practice? Does it suffer from stalls or keeping values alive too
> long?

There are definitely space-leak issues with pure region-based
management. In my experience, you need to profile your code and
insert region annotations and a few explicit deep copies to get rid of
space leaks. This isn't as difficult as it may sound, and you
typically only have to do it in a few places, but you certainly can't
expect off-the-shelf ML programs to have good memory performance with
regions.

That said, once you get the annotations in place, ML programs with
regions usually require less memory than with GC (unless you keep the
heap so small that you trash it).
Show full article (1.37Kb)
no comments
Re: Region-based memory management         


Date: Apr 7, 2008 00:56

torbenm@app-2.diku.dk (Torben Ægidius Mogensen) writes:
> The study administration system at the IT University in Copenhagen
> (which has Mads Tofte as headmaster) is implemented in ML and runs on
> the ML-kit. It did that even before GC was added, so you can
> certainly write significant programs that use regions exclusively.

Does that impose a particular style? What if you use functional data
structures extensively?
no comments
Re: Region-based memory management         


Author: Torben Ægidius Mogensen
Date: Apr 7, 2008 05:02

Paul Rubin <http://phr.cx@NOSPAM.invalid> writes:
> torbenm@app-2.diku.dk (Torben Ægidius Mogensen) writes:
>> The study administration system at the IT University in Copenhagen
>> (which has Mads Tofte as headmaster) is implemented in ML and runs on
>> the ML-kit. It did that even before GC was added, so you can
>> certainly write significant programs that use regions exclusively.
>
> Does that impose a particular style? What if you use functional data
> structures extensively?

I haven't seen the source code for the ITU administrative system, so I
can't really comment on its style. But I have tried some small
examples on the ML-kit with regions (without GC) and found that
functional data structures are not a problem, but that you sometimes
have to make a deep copy of a result of a lengthy computation to put
it in another region than that of the now-dead intermediate values for
the computation, so the latter can be reclaimed.

Torben
no comments

RELATED THREADS
SubjectArticles qty Group
US-MD: Columbia-Manager IT Project Management - Columbia, MDus.jobs.offered ·