Skip to content

Portal Memory Leak - Any portal opened remains in memory #4106

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Niallith opened this issue Nov 11, 2020 · 5 comments
Closed

Portal Memory Leak - Any portal opened remains in memory #4106

Niallith opened this issue Nov 11, 2020 · 5 comments

Comments

@Niallith
Copy link

Niallith commented Nov 11, 2020

Bug Report

Memory Leak with any component using Portal (Popup, Modal, etc...)

Steps

image

  • Hit Open/Close Portal many times
  • Do a Collect garbage then stop recording

image

Expected Result

Should not still have trace of all the portals opened during the record

Actual Result

Seems like all the portals previously opened remain in memory

Version

2.0.1

Testcase

https://codesandbox.io/s/u3j3w?module=/example.js

@welcome
Copy link

welcome bot commented Nov 11, 2020

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you've completed all the fields in the issue template so we can best help.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@layershifter
Copy link
Member

layershifter commented Nov 11, 2020

Thanks for reporting, but I haven't seen anything related to SUIR in snapshots, there is also no detached elements.

Few insights from our previous memory investigations:

  • use production builds with unminified symbols, for example react-scripts build --profile as CodeSandbox can have own leaks
  • press multiple times on garbage collector 👍

I captured two snapshots:
image
image

The single difference that I can see, it's growing amount of HTML*Element. The single visible reference that I can find points to React internals and FiberNode (it can be visible on unminified builds):

image

This looks related to facebook/react#16087 (see facebook/react#16087 (comment)) and a missing cleanup of FIbers facebook/react#18690. We also met this issue in Fluent UI.


Please correct me if I am wrong or missed something 🤔

@Niallith
Copy link
Author

Probably sure it's not related to semantic-react. It's strange you can't reproduce though 😢

I did more test with a production build, just using the PortalExamplePortal from semantic-react documentation
https://react.semantic-ui.com/addons/portal/#types-portal

I took those snapshots after opening/closing 30 Portal and I did hit collect garbage many times before 😄
image

I did a record performance/memory also:
Opening/closing Portals about 20 times, garbage collect, did this 3 times and got this result:
image

@Niallith
Copy link
Author

For example, I reproduce the same thing on Totoro (popup rating example), which create a Portal too.
If you hover/leave many times, the memory uses keep increasing in chrome (shift+escape)
image

When recording performance:
image

@Niallith
Copy link
Author

Well, never mind, I don't think my tests are relevant. At some points, React seems to clear those nodes.

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

No branches or pull requests

2 participants