[Haskell-cafe] Strange memory usage problem

Ketil Malde ketil at malde.org
Fri Jul 31 05:06:08 EDT 2009


I'm observing something I find quite strange.  I have a program that
normally streams through a file, and it runs in the expected constant
space, consuming about 5MB, according to 'top'.  When I uncomment a
certain block of code in the library it uses, space consumption
appears to grow linearly with the input size.

This is a bit surprising to me, since the code in question isn't used
by the program at all, and yesterday, Cale confirmed this behavior on
a recent GHC (6.10.3, I think - mine is 6.8.2 as shipped with Ubuntu

Since this appears to be reproducible, I put together a test case.
The steps are:

    darcs get http://malde.org/~ketil/biohaskell/biolib-unstable
    darcs get http://malde.org/~ketil/biohaskell/flower

Build them using the usual incantations (./Setup.hs

Download the test input file:

    wget http://malde.org/~ketil/test.sff

Run for instance this command line:

   fselect "And (Func GT len 100) (Func GT k2 0.5)" test.sff

This should now run in constant space.  To observe the linear growth
space, unpull the last patch from biolib, i.e. this one:

  Fri Jul 31 00:14:09 CEST 2009  Ketil Malde <ketil at malde.org>
    * comment out recover functionality - otherwise FSelect leaks memory!
      M ./Bio/Sequence/SFF.hs -1 +7

This uncomments some otherwise unused code, which apparently triggers
this behavior.  I'm unable to see what causes this, so any suggestions

If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-Cafe mailing list