markfarnan / go-canvas

Library to use HTML5 Canvas from Go-WASM, with all drawing within go code
Apache License 2.0
245 stars 20 forks source link

Memory / RAM Problem in Live Demo #6

Closed Thanson16 closed 4 years ago

Thanson16 commented 4 years ago

Hey there, looks like a really cool project. However, when I open the live demo I see massive memory usage. The application consumes around 10 GB in 30 seconds or so, before either the browser or I kill it. Problem tested and observed on the following:

Don't know if this is a sign of problems with the library or if it is specific to the demo though. Let me know if you'd like any more info from me.

justinclift commented 4 years ago

Interesting. Sounds like garbage collection isn't working properly in it. Or new buffers are being created with each frame, instead of re-using existing ones.

markfarnan commented 4 years ago

Looking into it. I'm not seeing the same issue with my local code on a quick check.

markfarnan commented 4 years ago

@Thanson16 @justinclift Fixed. Demo was old go version.

I have updated the demo to go 1.14 and the latest wasm_exec.js as well.

Whilst I had updated the library for 1.13 previously, the demo was still on old 1.11 which definitely has leaks. Also, 1.14 has additional cleanup for js_value in the GC now, which is nice.

I'm letting it run overnight to confirm, but seems OK in a short test.

Please check if this fixed it for you.

Thanson16 commented 4 years ago

Quick test on Firefox + Linux and all looks great! Thank you!

markfarnan commented 4 years ago

@Thanson16 Welcome. Let me know if there is anything you'd like to see added. I may have some time to do more work on this shortly.