Fixing memory leaks in web applications | Read the Tea Leaves
Modern web app frameworks like React, Vue, and Svelte use a component-based model. Within this model, the most common way to introduce a memory leak is something like this:
window.addEventListener('message', this.onMessage.bind(this));
That’s it. That’s all it takes to introduce a memory leak. If you call addEventListener on some global object (the window, the
, etc.) and then forget to clean it up with removeEventListener when the component is unmounted, then you’ve created a memory leak.
March 6, 2020 at 9:27:54 AM EST
*
FILLER