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

#2912 - fix memory leak for ketcher when it is opened inside modal #3027

Conversation

StarlaStarla
Copy link
Contributor

@StarlaStarla StarlaStarla commented Aug 3, 2023

How the feature works? / How did you fix the issue?

(Screenshots, videos, or GIFs, if applicable)

The root cause is the Editor's div ref is initially used to create root in initApp.tsx, while this root did not get destoried when Editor unmount because the ref is an escape hatch in react, which are out of react's control.
The listeners are subscribed in this root, so they did not get unsubscribed.
The fix is to create the root in Editor and umount it manually when Editor get destoried, then react would take care of unmount all the components and removing event handlers or state in the tree.

Please refer to this branch for a modal example to reproduce this bug: 2912-bug-fix-memory-leak-for-ketcher-when-it-is-opened-inside-modal-1
and this branch for fix with the same modal
2912-example-fix-memory-leak-for-ketcher-when-it-is-opened-inside-modal-1

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"

@StarlaStarla StarlaStarla linked an issue Aug 3, 2023 that may be closed by this pull request
@StarlaStarla StarlaStarla changed the title 2912 fix memory leak for ketcher when it is opened inside modal #2912 - fix memory leak for ketcher when it is opened inside modal Aug 3, 2023
…x-memory-leak-for-ketcher-when-it-is-opened-inside-modal
@Zhirnoff
Copy link
Collaborator

Zhirnoff commented Aug 9, 2023

Tested. Bug is fixed.

@Zhirnoff Zhirnoff merged commit 48d89cd into master Aug 9, 2023
@Zhirnoff Zhirnoff deleted the 2912-fix-memory-leak-for-ketcher-when-it-is-opened-inside-modal branch August 9, 2023 13:33
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.

Fix memory leak for Ketcher when it is opened inside modal
4 participants