[Gc] weak maps and libgc

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


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:


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?


More information about the Gc mailing list