Skip to content
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

Clear timers and event listeners before component unmounts #188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Arooba-git
Copy link

Hi 👋
Thank you for this handy utility!

We found there was an event listener and a bunch of timing events that were not cleaned up on component destruction, which led to their accumulation over time, causing memory leaks. This PR clears them just before the component unmounts. You can see the difference in the count of memory leaks as detected by Memlab.

Before
Screen Shot 2024-01-07 at 9 50 33 PM

After
Screen Shot 2024-01-07 at 9 50 57 PM

Copy link

vercel bot commented Jan 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auto-animate ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 16, 2024 11:06pm

@@ -25,8 +27,18 @@ if (typeof window !== "undefined") {
clearTimeout(resizeTimer)
window.addEventListener("resize", () => {
resizeTimer = setTimeout(applySizing, 200)

this.$once('hook:beforeUnmount', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$once is removed in Vue 3.

:hook event prefix has also been replaced with vnode-

https://v3-migration.vuejs.org/breaking-changes/

Copy link
Author

@Arooba-git Arooba-git Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delayed response. Somehow I missed the notification for this. Updated now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants