Space usage

Lennart Augustsson lennart at
Wed Aug 18 11:56:53 EDT 2004

Adrian Hey wrote:
> On Tuesday 17 Aug 2004 5:11 pm, Malcolm Wallace wrote:
>>It is also possible to use Wadler's
>>garbage-collector fix for this space leak, as implemented in nhc98.
>>    P Wadler, "Fixing a Space Leak with a Garbage Collector", SP&E Sept
>>When the GC discovers a selector function applied to an evaluated
>>argument, it "evaluates" the selector on-the-fly by just swizzling
>>pointers.  It needs some co-operation from the compiler to make
>>selector functions look obvious, but that isn't too difficult.
> So ghc doesn't do this (or something better)? I'm surprised
> because it seems like a really basic and simple feature to me. I
> implemented a toy FPL a few years ago and even my gc incorporated
> this optimisation. It's a bit strange that this should have been
> overlooked considering in all other respects ghc is far more
> sophisticated than my efforts were :-)

As Simon pointed out, it's not so easy to do this with an
optimizing compiler that may inline selector functions.

The "right" way to do this is to have specialized code
that runs during GC for each thunk.  This was investigated
in Christina von Dorrien's licentiate thesis "Stingy evaluation".

	-- Lennart

More information about the Glasgow-haskell-users mailing list