[Haskell-cafe] Soft references
Duncan Coutts
duncan.coutts at worc.ox.ac.uk
Wed Apr 18 19:48:42 EDT 2007
On Wed, 2007-04-18 at 16:17 +0300, Benja Fallenstein wrote:
> Hi all,
>
> Is there a way to achieve the effect of soft references in GHC? Or if
> not, is there any hope that they will be implemented in the future?
> (Soft references are like weak references, except that they are only
> reclaimed by the garbage collector if memory is short.)
Oh, and we could do mmap-like things for lazy random IO on (read-only)
files.
Take a finger tree of strict chunks where each chunk is lazily read in
from a span in the file (using unsafeInterleaveIO and seek) but then
instead of holding that chunk in memory for evermore (well, at least as
long as the whole finger tree is kept alive) if that chunk is not being
used any more and only being referenced through the finger tree then
when memory is tight we can just forget it and re-read it later if we
get asked for it again. This might work with weak references at the
moment but 'soft' references would probably suit it better.
Duncan
More information about the Haskell-Cafe
mailing list