[Haskell-cafe] Memory Management and Lists

Will Yager will.yager at gmail.com
Sun Jul 10 17:26:03 UTC 2016


I'm not an expert here, but the GC should not allow that to happen if you were truly no longer using the elements. Most likely you have a dangling reference to the list head or something. Please post your code. 

Will

> On Jul 10, 2016, at 11:41, Christopher Howard <ch.howard at zoho.com> wrote:
> 
> 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).
> 
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.


More information about the Haskell-Cafe mailing list