[gclist] Re: gclist-digest V3 #84

Burton, Joshua jburton@Rational.Com
Wed, 21 Jun 2000 17:16:08 -0500


Richard A. O'Keefe wrote:

> Surely Erlang can't be the only system with a per-thread heap?
> (The concurrent version of Quintus Prolog, which Tim Lindholm built,
> also did this, if I remember correctly.)  The reason for having a
> per-thread heap is precisely so that other threads *don't* need to
> be stopped.

The difficulty comes when threads get pointers to the heaps of other
threads (as they must; if you weren't sharing memory between threads,
you'd use separate process spaces, stop tearing your hair out, and
spend more time with the wife and kids).  In the extreme case, a
producer-consumer thread pair can consume unbounded memory if the
consumer can't get access to the producer's freelist, and instead
squirrels all the dead memory away uselessly in its own.  The Hoard
paper shows an efficient implementation that avoids this without too
much thread collision (N local heaps and a global heap, with an
explicit limit on how much freelist a local heap may hang onto), but
this is a compromise, not a complete answer.

If your collector permits other threads to manipulate your freelist
without a lock, then you don't have this problem.

There will be always Evils, which   +-------------------------------------+
no Arte of Man can cure, Breaches   |  Joshua W. Burton    (847)677-3902  |
and Leakes moe then mans Wit hath   |         jwb@post.harvard.edu        |
Hands to stop.  -- Hooker (1597)    +-------------------------------------+