Slightly lighter than HashSet<WeakReference> – HashSet<GCHandle> (an experiment)

In playing around with the possible solutions or improvements to [previous post:] the heaviness of finalizable WeakReference objects, an obvious thing to do was replace WeakReference objects with using GCHandle structs. Here’s a test program which adds many WeakReferences to a HashSet. (Note, HashSet uses arrays as the underlying storage.) The WeakReferences will point at…

2

WeakReference collections and the heavy WeakReference class

Briefly diverging from regular posts: here’s something really fun. As far as I know, prior to 4.0, .Net has had, two built in ways to do weak object references. 1) WeakHandle 2) GCHandle, which is what WeakHandle uses under the covers. If you have ever tried to use WeakHandle in a collection, e.g. attempt to…

1