Simon Peyton-Jones <[EMAIL PROTECTED]> wrote:

> Consider the Data a branch. It'll be compiled to
>       let t = build es
>           siblings = fst t
>           rest     = snd t
>       in ...
> In many implementations, until you evaluate 'rest', you'll
> keep the whole of 't'; which in turn contains 'siblings'.
> So there's a danger of a leak here.

That's more or less what I suspected...

> GHC does a standard trick, which is to perform the 'snd'
> in the garbage collector, so the original form shouldn't
> leak.  I don't think Hugs does.  (But it will when we release STG
> Hugs.)

That must be it!

I just tried the developer snapshot of STG Hugs, and (since
I couldn't get the profiler to work) ran it with a heap size
just big enough to hold the Prelude and my test case, plus ~10K
words to spare.

After fixing the *other* space leak that Malcolm Wallace noted,
(too much laziness in 'length' and 'sum') all the tests ran without
a problem.  That was using breadth=12 and depth=6, which makes Hugs98
run out of room even with the default heap size.

Problem solved!  Thanks!


--Joe English

  [EMAIL PROTECTED]

Reply via email to