CreateJS / TweenJS

A simple but powerful tweening / animation library for Javascript. Part of the CreateJS suite of libraries.
http://createjs.com/
MIT License
3.56k stars 967 forks source link

Bug: memory leak when rendering is not taking place #77

Closed please-wait closed 8 years ago

please-wait commented 8 years ago

I have tried this a few times on a powerful system, it's pretty easy to reproduce: I go to the tween demo click on a few ease types and leave the tab; after a few minutes, an "Aw, snap" shows up on that tab saying I need to free up more memory.

Task manager and Timeline don't show noticeable memory leak while the tab is in focus. After switching to another tab it starts eating memory. Looks like there is a cleaning action that is triggered with rendering (requestAnimationFrame?).

lannymcnie commented 8 years ago

Does this happen in a particular browser? Unable to reproduce in the few browsers that I tested.

please-wait commented 8 years ago

Latest version of Chrome on windows 10. If you switch to another tab, you can see it climbing to the top in Chrome task manager: image

lannymcnie commented 8 years ago

Thanks, we were able to verify. We will try and narrow down what is causing the bug. If you have any additional findings, let us know.

please-wait commented 8 years ago

I will. Thank you and best of luck.

lannymcnie commented 8 years ago

This issue turned out just to be the demo code. When the tween completed, it never stopped running the draw function, so it would add instructions to the graphics every tick. If you pile on enough graphics instructions, apps can get very slow - so it is important to properly manage this process.

We have fixed the demo in question, and will push it to GitHub/CreateJS.com shortly.

Thank you very much for identifying this issue!

please-wait commented 8 years ago

Good to hear it was easy to fix. I think it might be a good idea to reflect these findings on the wiki of the project so that other developers won't do it the wrong way.