skoppe / spasm

Write single page applications in D that compile to webassembly
MIT License
218 stars 17 forks source link

events leak #11

Open WebFreak001 opened 5 years ago

WebFreak001 commented 5 years ago

https://wfr.moe/fwJGWM.png

Every event seems to get added to that objects list and not removed

Using the dom example pretty much

skoppe commented 5 years ago

I am aware. You can call spasm_removeObject to manually clean it from D. But it should simply happen automatically.

The Spa framework doesn't have this issue because it handles events in another way. But for the bindings this is a very serious issue.

I already have a solution for it. It just never has been high on my priority list. But it just jumped to no. 1 :)

skoppe commented 5 years ago

I have an update for you.

The 0.2.0-beta.1 version fixes the leak by automatically calling spasm_removeObject.

It works by making the underlying JsHandle non-copyable, so there is only 1 alive at all times (not counting scoped refs via dip1000 and dip25). Since there is only 1, it just frees the JS referenced object at destruction.

Hope you can find some time to try it.