The attached test case quickly chews up hundreds of MB of memory.
If modified to call work' instead, it runs in constant space.
Somehow the value repeatedly read in from the file and stored in
the state is leaking. Can anyone help me understand why?
(ghc 7.0.4)
--
see shy jo
{-# LANGUAGE Genera
Hi,
On 30/01/12 01:07, Joey Hess wrote:
The attached test case quickly chews up hundreds of MB of memory.
If modified to call work' instead, it runs in constant space.
Somehow the value repeatedly read in from the file and stored in
the state is leaking. Can anyone help me understand why?
Con
Claude Heiland-Allen wrote:
> Control.Monad.State.Strict is strict in the actions, but the state
> itself is still lazy, so you end up building a huge thunk in the
> state containing all the updates that ever took place to the initial
> state.
>
> Using this should fix it:
>
> modify' :: MonadSta
Have you tried to compile your code with optimisations? I guess GHC's
strictness analysis would find strict evaluation is better here.
2012/1/30 Joey Hess
> Claude Heiland-Allen wrote:
> > Control.Monad.State.Strict is strict in the actions, but the state
> > itself is still lazy, so you end up
Yves Parès wrote:
> Have you tried to compile your code with optimisations? I guess GHC's
> strictness analysis would find strict evaluation is better here.
The original code I saw this happen to the wild was built with -O2.
I didn't try building the test case with optimisations.
--
see shy jo