-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Canvas draw and animation creating Memory Leaks #1084
Comments
OK EVERYONE!! I can't believe i didn't think to try this earlier ... but i believe i have made a HUGE improvement to performance and memory usage!! VERY SIMPLY ... ALSO, at the end of those calls, i cancel the request and Here is what i did ...
And then of course i did the same for the I am betting there are other improvements that can be done as it relates to memory leaks, like nulling properties when they are no longer needed, but i feel like this alone makes for a great improvement. Hey @entonbiba, can this update be applied to the latest version? With all that said though ... i should point out that when destroying a wave instance, the memory that is used is still NOT released ... VERY important to note ... so this issue should remain open. I believe though that the memory usage that is never released is likely related to the canvas elements and not necessarily the In the meantime im working to apply the same idea to other methods like Cheers!! |
@gitdisrupt looks fine to me, can you create a pull request for it? |
@gitdisrupt @mspae @katspaugh I say let's create a util method for |
This looks cool, @gitdisrupt, thank you very much! @entonbiba I agree. Actually setting to null looks like some black magic. Does it really do anything? Doesn't the |
Yes, I see a lot of memory leaks on destroy in relatively young libraries, too. Setting those values to null won't do anything. PR coming... |
* Wrap drawing in requestAnimationFrame. Wrap drawing in requestAnimationFrame per #1084. * Update drawer.canvas.js * Update drawer.canvas.js * Update drawer.canvas.js * Update drawer.canvas.js * Update drawer.canvas.js
Closing this since the PRs were merged. |
Wavesurfer.js version(s):
1.4.0
Browser version(s):
Safari and Chrome
Use behaviour needed to reproduce the issue:
All use cases ...
I was seeing a never ending increase in memory usage when instantiating a wavesurfer instance and playing back an audio file (tried both, as
MediaElement
andWebAudio
) that is NOT released after callingmyWave.destroy()
to destroy the instance.At first i suspected the memory leaks had something to do with WebAudio or even the Media element, but then to test this theory, i modified the wavesurfer code and disabled the render of the canvas.
As soon as i disabled the render of the canvas the memory leak was gone.
It seems there are references to the canvas elements, event listeners and animation that are not properly removed on destroy.
The text was updated successfully, but these errors were encountered: