[Haskell-cafe] Memory Management and Lists
Christopher Howard
ch.howard at zoho.com
Wed Jul 13 03:28:05 UTC 2016
After pondering this problem some more, I found a solution to the
problem was to introduce strictness, not deep down in the StateReader
monad, but rather at the top level, i.e., forcing evaluation of each
Matrix as soon as it is pulled of the list of Matrices. I found I could
do this simply by summing all the elements in each matrix and printing
the sum to std out. With this approach, i successfully run the full
program and never even saw my memory performance graph move up.
I suppose there might be a way to do the same thing more efficiently
with seq...?
On 07/12/2016 06:39 PM, Christopher Howard wrote:
> I guess I was hesitating on posting the entire program source code in an
> cafe email. I suppose I could send you a tarball, if you really wanted it...
>
> Matrix is from Data.Matrix
> <http://hackage.haskell.org/package/matrix-0.3.5.0/docs/Data-Matrix.html>.
>
> It is hard to understand how thunks alone would explain it... there
> would be at most 2000 thunks, right? Unless... Could there be a thunk
> for every single call to getElem? That would be a lot of thunks!
>
> Somebody suggested adding some strictness here... could you elaborate on
> that? I tried inserting seq, but I didn't really understand how I was
> supposed to use it...
>
--
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