Use finalizers to clean up memory in the interpreter
Finalizers should be added to the host_references
so that lost references from the host can be cleaned up.
Also, a finalizer should be added to CoerceEnvironment
so that the whole interpreter can be cleaned up when everything has been copied from there.
This is what it should look like (not showing the values and finalizer in CoercionEnvironment
). Because the finalizer links back to the coerce
node, we can get the CoercionEnvironment
from the cleanup()
function to update the list of host references in there.
Edited by Clean Importer