Skip to content

Remove dangling event listener to avoid memory leaks - #43

Closed
Arooba-git wants to merge 1 commit into
tbtMEC:mainfrom
Arooba-git:main
Closed

Remove dangling event listener to avoid memory leaks#43
Arooba-git wants to merge 1 commit into
tbtMEC:mainfrom
Arooba-git:main

Conversation

@Arooba-git

Copy link
Copy Markdown

Hello 👋
As part of our project, we are using Facebook's new Memlab tool to detect memory leaks in SPA applications.
While running the tool and analyzing the code of TBT, we saw that it does a very good job of ensuring that all async operations are cancelled when the component unmounts. However, as per Memlab execution results, we found that the removal of the event listener is forgotten in one place and is causing the memory to leak (screenshots below).

[before]
Screen Shot 2023-01-24 at 2 15 28 AM
Screen Shot 2023-01-24 at 2 15 54 AM
Hence we added the fix by removing the event listeners and you can see the heap size and # of leaks reducing noticeably:


Screen Shot 2023-01-24 at 2 21 33 AM
Screen Shot 2023-01-24 at 2 20 46 AM

You can test this and other potential leak sources, if you like, by running Memlab with a scenario file covering the maximum # of use cases.

Following is a sample of the scenario file we used (it needs to be a .js file but attaching here in txt form):
test-scenario-tbt.txt

Note that some other reported leaks originate from React's internal objects, hence ignored.

@netlify

netlify Bot commented Jan 23, 2023

Copy link
Copy Markdown

Deploy Preview for the-book-thieves ready!

Name Link
🔨 Latest commit f210729
🔍 Latest deploy log https://app.netlify.com/sites/the-book-thieves/deploys/63cec493c8f00c0008036646
😎 Deploy Preview https://deploy-preview-43--the-book-thieves.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@Arooba-git

Copy link
Copy Markdown
Author

bump @ashikkl

@tbtMEC tbtMEC closed this Apr 22, 2023
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