replit / kaboom

💥 JavaScript game library
https://kaboomjs.com
MIT License
2.67k stars 226 forks source link

Memory leak: SpriteData.from/SpriteData.fromImage #741

Closed codingMASTER398 closed 1 year ago

codingMASTER398 commented 1 year ago

Using SpriteData.fromImage repeatedly with a large texture, although setting the SpriteData to null, increases memory & slows the game to a halt.

This is demonstrated in a JSFiddle. Each frame, 4 707x707 black images are fed into SpriteData.fromImage and used as a sprite for 4 tiles. After just a few seconds, the frame rate suddenly drops with the page following suit. All relevant code is contained there & commented.

500 Replit cycles to whoever can get a fix/alternative!

codingMASTER398 commented 1 year ago

Fixed by freeing textures after using them, something not outlined in the docs. Created a PR to fix that: https://github.com/replit/kaboom/pull/743