[Gc] weak maps and libgc

Andy Wingo wingo at pobox.com
Fri Oct 21 04:31:14 PDT 2011


Hello,

I and a few others have written in the past about the difficulties of
implementing weak maps with libgc.  Properly implementing weak maps
requires GC integration.  Currently I do terrible things with the pre-GC
hook marking a flag that causes a vacuum procedure to run after GC.  I
had not thought about the problem of cycles from values to keys in
key-weak maps though:

  http://www.jucs.org/jucs_14_21/eliminating_cycles_in_weak/jucs_14_21_3481_3497_barros.pdf

To implement this sort of thing, you need tighter GC integration.  But
providing those hooks limits the GC.  To avoid publically exposing those
hooks, it would be possible to incorporate a weak map or weak set
implementation into libgc itself.  What do you think?

Andy
-- 
http://wingolog.org/


More information about the Gc mailing list