[MLton-devel] Minimizing space usage in ML (fwd)

Joe Hurd joe.hurd@cl.cam.ac.uk
Wed, 23 Oct 2002 00:49:46 +0100 (BST)


I did think about implementing my own hash-consing using the scheme
you suggest with weak pointers, but I decided that I'd prefer to keep
my code natural and concentrate on better algorithms rather than
low-level optimizations. I think this approach has paid dividends, but
it is rather frustrating when the occasional problem causes the
program to go haywire and eat up 2Gb of RAM...

Regards,

Joe

On Tue, 22 Oct 2002, Matthew Fluet wrote:

>
> > > The idea that Henry mentioned:
> > > is practical and eliminates all duplicates in an object or even the
> > > entire heap by combining copying GC with hash consing.
> >
> > I'm extremely pleased to hear that there is a practical scheme to do
> > this on your to-do list, but I'm afraid I'm not a compiler hacker,
> > just a user who repeatedly constructs lots (sometimes gigabytes) of
> > immutable similar objects :-(
>
> Note: you can generally implement hash-consing yourself, especially if
> your data is AST-like (as opposed to, say, integer lists).
>
> There still isn't as much compiler support there as one might hope.  If
> you don't periodically empty the hash-table, you can still end up
> retaining a significant number of objects that are only reachable through
> the hash-table.  Weak pointers would help in this context.  The hash-table
> can still contain a lot of entries if you don't clear out the NULLed
> pointers, but presumably those pointers are much smaller than the object
> they were pointing at.  (And, I think, one could fairly easily amortize
> the cost of clearing NULLed pointers across insert and lookup functions.)
>
>



-------------------------------------------------------
This sf.net emial is sponsored by: Influence the future 
of Java(TM) technology. Join the Java Community 
Process(SM) (JCP(SM)) program now. 
http://ad.doubleclick.net/clk;4699841;7576301;v?http://www.sun.com/javavote
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel