Space leak

Christian Maeder maeder at tzi.de
Tue Dec 27 14:12:20 EST 2005


Chris Kuklewicz wrote:
> Greg Buchholz wrote:
>>     True.  But there are some tests like "fasta" that appear to have a
>> laziness induced space leak that presumably could be fixed.   
>>
>> http://shootout.alioth.debian.org/benchmark.php?test=fasta&lang=all

Already the following bit exhibits unexpected memory consumption:

main = mapM_ print $ take (n * 5) $ drop (n * 3) [1..]
n = 100000

Dropping the elements is more expensive than printing them. Somehow the 
dropped elements are kept in memory.

With profiling (compiled with -prof -auto-all and called with +RTS -p) 
the memory consumption is not reported, at least the "total alloc" bytes 
are not much different with and without the "$ drop (n * 3)" part.

Only my /usr/bin/time -v shows:

         Minor (reclaiming a frame) page faults: 4745

for the code above (compiled with optimization) and about ten times less 
  without drop.

Cheers Christian



More information about the Glasgow-haskell-bugs mailing list