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

Travis Erdman traviserdman at yahoo.com
Mon Apr 12 13:11:21 EDT 2010


> I take it that size of the array does not depend on  arg ?

> Apparently, despite your attempts to force evaluation, the array still
> contains many unevaluated expressions. Documentation for the  vector
> pacakge reveals that  Data.Vector  is a *boxed* array, i.e. the entries
> are only evaluated on demand, so that's where the unevaluated
> expressions linger around.

> Unless you need the extra laziness - which you probably don't, given how
> you've structured your algorithm - you might want to switch to
> Data.Vector.Unboxed  or  Data.Vector.Storable.

Correct.  The array size doesn't depend on arg (arg only controls how much
of the input list to process.

I did not realize that the boxed arrays would have this extra-lazy behavior.
The reason I chose boxed is because I needed to store these very large trees
(custom data type) that I referenced in an earlier question.  Since D.V.Unboxed
and Storable don't appear to support non-standard data types, is there another
package that might better fit my needs?  Data.IntMap perhaps?  I originally
chose an array over a map because I need fast random access to individual
elements (and cheap modification).

Thanks again,

Travis Erdman



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


More information about the Beginners mailing list