StateT space leak

Tomasz Zielonka t.zielonka at students.mimuw.edu.pl
Fri Nov 14 02:00:38 EST 2003


On Fri, Nov 14, 2003 at 12:22:00AM +0100, Tomasz Zielonka wrote:
>
> There is more to it. Let's define
>
>     t2 :: IO ()
>     t2 = sequence_ $ repeat $ return ()
>
> t2 behaves in the same way. However, if you compile the module with
> GHC
> with optimisations turned on, both t and t2 run in constant space. OK,
> I
> understand that GHC doesn't do optimisations in interpreted code.
>
> The strange thing is that if you execute
>
>     *A> runStateT (sequence_ $ repeat $ return ()) 1 :: IO ((), Int)
>
> directly in GHCi, then is seems to run in constant space.

I guess it is an infamous CAF leak - f expands into an infinite
expression which can't be reclaimed because it is bound to a top-level
variable. When compiling with optimisations GHC somehow manages to avoid
this problem.

Can somebody confirm this?

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links


More information about the Haskell mailing list