Finalization not working
I can't get the gc to run a destructor..
At first I thought that I'm making some kind of mistake here but I don't know where..
I was trying to make a Drop trait
Then I tried to copy some code that seemed to work from a conf and also mdn but the destructor was never called..
2 Replies
FinalizationRegistry
only calls the callback after the object is GC'd
which means at that point there can't be any remaining references to the GC'd object
I think () => this.drop()
is actually keeping a reference to this
alive
which means there is no point at which there are no remaining references
in JS there's no way to have a destructor that accesses the object
the closest you can have is the using
proposal (currently stage 3)I can't trust the user yk..
It's not guaranteed that he/she will declare the object using
using