[Haskell-cafe] Memory Management and Lists

Christopher Howard ch.howard at zoho.com
Sun Jul 10 15:41:31 UTC 2016


Hi, short version of the question: when elements are 'drop'ped from a
list, when is the memory for those elements released? And is there some
way to control that?

Longer version: I have this situation where I've got a State monad
carrying a Data.Matrix, and I...

1) generate in infinite list of monadic operations with (repeat mf)
where mf is a monadic function.
2) 'sequence' (from Control.Monad) to get a monad containing the
infinite list of all states (i.e., a list of Matrices).
3) evalState(T) to extract the list
4) extract the nth state with (head (drop (n-1)))

I like this approach. However, there seems to be a memory management
issue: a Matrix itself should only be, I'm guessing, somewhere around
100KB. But instead I'm maxing out the 3GB of RAM on my old T60 laptop.
Maybe I'm generating list elements (Matrices) a lot faster than memory
management is releasing them...?

-- 
http://qlfiles.net
To protect my privacy, please use PGP encryption. It's free and easy
to use! My public key ID is 0x340EA95A (pgp.mit.edu).



More information about the Haskell-Cafe mailing list