euvl / vue-notification

:icecream: Vue.js 2 library for showing notifications
http://vue-notification.yev.io/
MIT License
2.39k stars 213 forks source link

Fix memory leak #247

Closed feliperaul closed 2 years ago

feliperaul commented 3 years ago

Changes in PR:

In the mounted hook, we add event listeners that we never remove. This PR removes them on beforeDestroy.

I was facing a memory leak in our Rails/Vue application, and using the memory tab in DevTools it was easy to see that the lib was the culprit (screenshot below); without this fix, the entire Vue app that relies on vue-notification will always be kept in memory even after unmounting; we even call $destroy on our app instances directly, because it's a Rails/Turbolinks app so we need to cleanup after ourselves, but even with that the lib will retain the entire app in memory.

In our app, after switching screens 10 times, without this fix, memory usage goes to 150MB. With this fix, it comes back down to 20mb.

image

github-actions[bot] commented 2 years ago

Stale pull request message

feliperaul commented 2 years ago

Can this please be reopened?