-
Notifications
You must be signed in to change notification settings - Fork 5
Description
I was thinking of starting work on the screen library/console as some of the features I want to add to Windows would benefit from having some of the parent class set up. However, since screens would later open up the ability to have multiple WASM programs running at the same time, I wanted to see if that was possible.
From what I have seen, there's several dependencies that seem to prevent WASM modules from being garbage collected. I've done some testing on an isolated branch adding WeakRef's to several sections to allow a WASM module to be garbage collected. However, I'm not sure what a good solution to this sort of thing would be. Especially since the method I was using would allow used WASM modules to be cleaned up despite still having a bound window and render loop. I'm not quite sure what the proper solution would be in this case. Maybe when the ability to dynamically load modules becomes a thing they're added to a global registry that you call .close() on to allow it to be collected? I'm not quite sure.
Additionally, I'm not sure how well it works with the async variant. I can get the main thread reference to garbage collect and I can terminate the worker thread. However, I'm not exactly sure if that means it's actually been collected as the worker object doesn't seem to get collected for some reason I haven't been able to trace.
In all, I'm not sure what should be done about this. It's not super important for now since every module is statically defined, however, it will probably be important once they can be loaded dynamically. For now, I will push my testing to an isolated branch on my fork and continue working on the screen and window classes.