[Haskell-cafe] Squashing space leaks

Greg Buchholz haskell at sleepingsquirrel.org
Fri May 6 13:28:35 EDT 2005


Josef Svenningsson wrote:
> Greg, you express the sequential computation of updating the set of
> planets as an iteration over a list. This is a sweet way of expressing
> it but doesn't work very well when an element of the list contain
> pointers to the previous element. This will force all the elements to
> be in memory at the same time. What causes this is too little
> strictness, all computations which depend on the previous element
> haven't been forced and thus still points to it. It this specific
> program the problem is the list of planets. Even if we may have
> computer ourselves a new list of planets the planets themselves
> haven't been computed yet and will contain pointers to the previous
> list of planets. Devastating! Hence we will need a strict list to do
> this or some other strict data structure.
> 
> So, here's my code. It's not beautiful but it solves the space
> problem. I hope I got it right this time :)

    Alright, looks good.  I've incorporated this latest change.  You can
see the code...

    http://xrl.us/fzn4

Greg Buchholz


More information about the Haskell-Cafe mailing list