[Haskell-beginners] Space leak in a fold even after the usual fixes

Travis Erdman traviserdman at yahoo.com
Mon Apr 12 03:38:32 EDT 2010


The driver of my algorithm looks like this:

foldl' processfn nullarray (take arg infinitelist)

where processfn takes an array and the next set of inputs,
processes, and delivers a new updated array (using the
Data.Vector library).
 
Apparently, I have a space leak ... the "maximum residency"
varies linearly with the size of "arg" supplied, garbage
collection consumes ~75% of CPU time, and, if the arg is too
big, the whole thing crashes with an out of memory
error.  The algorithm should operate in constant
space.

As you can see, I'm using a strict left-fold and also have
made the accumulating array strict in the processfn
definition with a bang pattern.  So, I'm sort of at a
loss as to how to resolve this.

The help provided on this list has been outstanding, thanks
to all of you; hope you have something left in the tank for
this one!
 


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100412/30e5381e/attachment-0001.html


More information about the Beginners mailing list