ajvincent / composite-collection

Composing Maps, WeakMaps, Sets and WeakSets into compiled classes
Mozilla Public License 2.0
1 stars 0 forks source link

StrongMapOfWeakSets requires FinalizationRegistry for outerMap cleanup #41

Closed ajvincent closed 3 years ago

ajvincent commented 3 years ago

Otherwise, it leaks memory for holding a bunch of WeakSets or WeakMaps.

ajvincent commented 3 years ago

Basically, I have to reference count the members of the WeakSets or WeakMaps.

ajvincent commented 3 years ago

Another reason this has to wait: the need to hold strong references for the map keys. Right now there's a test I'm adding that fails for this. But to properly lose the strong references in a delete() operation, I would need to know that there aren't any remaining references among the weak sets.

In fact, the deleteSets() operation would be the only way to guarantee that the strong references could be deleted.

This particular template is looking more and more like a bad idea.