mmap and IArray slices

David Roundy droundy@abridgegame.org
Mon, 28 Apr 2003 08:12:28 -0400


On Sat, Apr 26, 2003 at 05:40:23PM +0100, Duncan Coutts wrote:
> On Sat, 26 Apr 2003 12:21:52 -0400
> David Roundy <droundy@abridgegame.org> wrote:
> 
> > I had a couple ideas, and I was wondering if they were good ones.
> > 
> > One is the idea of a slice function on an IArray:
> > 
> > a' = slice a (i,j) giving an array with the elements i..j of array a.
> > 
> 	[..]
> > I'm thinking that it may even be possible to make the GC smart enough
> > to get rid of mother strings which are needed by very few children (at
> > least if it's desperate), if array slices were supported at a low
> > enough level... I imagine they'd have to be supported at a very low
> > level.
> 
> Perhaps it could be done with cunning use of finalisers. Instead of
> having the substrings keep references to the 'mother' string, you could
> reverse it, so the mother keeps (weak?) references to the substrings.
> That way, when the mother string is garbage collected it can make copies
> of the substrings in new storage.

Oooo, that sounds like a great way to do things.  I had no idea you could
do that! :) The same sort of trick could also be used to deal with the
mmaped file situation where the file needs to be closed and you want to
unmap the file (but need to know who is referencing that memory, since it's
about to be made invalid).
-- 
David Roundy
http://www.abridgegame.org