On Sun, Mar 05, 2006 at 12:51:13AM +0100, Julian Rohrhuber wrote:
An array that has been marked weak should behave as if it could not
contain pointers (i.e. it is not scanned any further by marking it
...snip...
collected).
This would fail in the (improbable?) case that an equal object is
stored at the same memory address again.
nice idea, but there appears to be a problem: memory isn't
necessarily reused directly after finishing a collection, so
the weak array may point to an `object' that is still equal
to the copy but contains dangling pointers.
another proposal: a WeakArray points to instances of
WeakPointer, which store a reference to the array, their
index and the actual data. when the WeakPointer is finalized
(at the beginning of a flip), it nils the corresponding slot
of its WeakArray in the finalizer func. the downside is that
you have to deal with WeakPointers explicitly and not keep
references to the data they point to.
and another one: keep a weak identity dictionary at a
special global location; before a flip, scan the white list
for objects contained in the weak dict and nil any slots
found. the downside is that flips are not in O(1) anymore
(they aren't anyway with finalizers).