Skip to content

Clear intervals to avoid detached components and memory leaks#331

Merged
prc5 merged 1 commit into
BetterTyped:masterfrom
Arooba-git:master
Jan 24, 2023
Merged

Clear intervals to avoid detached components and memory leaks#331
prc5 merged 1 commit into
BetterTyped:masterfrom
Arooba-git:master

Conversation

@Arooba-git
Copy link
Copy Markdown
Contributor

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 react-zoom-pan-pinch, we saw that your project 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 some dangling intervals that were causing the memory to leak (screenshots below).

[before]
Screen Shot 2023-01-24 at 11 20 05 AM


Hence we added the fix by clearing the intervals and you can see the # of leaks reducing noticeably:


Screen Shot 2023-01-24 at 11 21 22 AM

You can analyze this and other potential leak sources, if you like, by running Memlab with a scenario file covering 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-menlab-rzpp.txt

Note that some other reported leaks (in Memlab) originated from React's internal objects, hence were ignored.

@Arooba-git Arooba-git requested a review from prc5 as a code owner January 24, 2023 02:40
@prc5 prc5 merged commit 584f197 into BetterTyped:master Jan 24, 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