[Haskell-cafe] memory usage: general questions
Christopher Howard
ch.howard at zoho.com
Wed Aug 3 04:54:36 UTC 2016
Hi. I've spent the last few days reading about strictness,
non-strictness, laziness, thunks, and persistence, and to be honest I'm
still in a bit of a fog. A few questions, which I hope might help me out:
Supposing I have an expression
f (f (f b)))
where f :: B -> B
and B is some ginormous persistent data structure.
and f is an "updating" function outputting some modified copy version of
it's argument
So, a few questions:
1) Supposing that f does not short-circuit: Is it correct to say that it
is definitely advantageous (from a memory usage perspective) for f to be
a strict function? Or is this heavily dependent on whether or not b
contains unevaluated data structures (e.g., a list)?
2) As far as the overall peak size of our memory graph: How will it be
affected by the size of b, if f is non-strict? and if f is strict?
3) Are the "overwritten" portions of each B (i.e., those parts of the
persistent data we no are no longer needed) guaranteed to be pushed out
of memory at any particular point? Is this something we know will
(might?) happen as soon as the GC is run? Or does it happen right when
each f is applied to it's argument?
--
https://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