However, after compiling with optimisations turned on, there is no such problem with the continuation-based version, memory usage appears constant.
- Cale On 4/14/05, ChrisK <[EMAIL PROTECTED]> wrote: > Thanks for the Cont example, David. But... > > The MonadCont is clever and it works ... but then fails -- ghci does > not garbage collect and it blows up. > With the MonadCont version I can count up to 10^7 zeros: > > *Main> length $ take (10^7) zerosInf > 10000000 > (26.20 secs, 0 bytes) > > But this increases RSIZE of ghc-6.4 to 165MB. The 10^8 version goes to > swap space and I had to kill it. My original MonadWriter version does > not increase RSIZE when run (constant space), so the garbage collection > must be working, and it is O(N) in the # of zeros counted: > > *Main> length $ take (10^7) zerosInf > 10000000 > (1.22 secs, 0 bytes) > *Main> length $ take (10^8) zerosInf > 100000000 > (10.05 secs, 0 bytes) > *Main> length $ take (10^9) zerosInf > 1000000000 > (109.83 secs, 6 bytes) > > -- > Chris > _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell