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

Bug: Chrome dev tools memory leak heads up #31929

Open
faridsaid20 opened this issue Dec 28, 2024 · 0 comments
Open

Bug: Chrome dev tools memory leak heads up #31929

faridsaid20 opened this issue Dec 28, 2024 · 0 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@faridsaid20
Copy link

faridsaid20 commented Dec 28, 2024

TLDR: There is a bug with Chrome dev tools that prevents nodes to be garbage collected ( detached nodes )

I noticed a lot of detached nodes when navigating in my Vite react 18 app.
Thought it was something with react-router, but then tried with tanstack router and there was the same issue.
Later I could reproduce the bug with raw react code. So I spent last few days deep diving into react source code until it lead to pure JavaScript events causing this...

By the end I figured out that it was chrome dev tools causing this, they start tracking on all events that won't allow garbage collection or something like that. And it is relatively new bug.

Tested with chrome 83 and 104. No issues with detached nodes...
Not sure which version of chrome introduced this. But beware memory leak bug reports that could come soon.

Here is the video of the same code with chrome 104 (left) and chrome 131 (right)

memoryleakChrome.mp4

React version: Tested with 16, 18 and 19

Steps To Reproduce

  1. Open codesandbox. There is a button called "open in a new tab", click it.
    image

  2. Open chrome dev tools.

  3. In the video I used performance monitor. But you can track memory leaks however you want in Memory tab.

  4. Each time you click on event button and then on render button it will fail to garbage collect previous nodes.

To make sure that it is chrome dev tools and not react.

  1. Open the same sandbox preview in new tab. Don't open dev tools yet.
  2. Start clicking on event and render buttons dozen times.
  3. Open dev tools and see that there are no detached nodes.

Link to code example: https://codesandbox.io/p/sandbox/lingering-bash-lschws

The current behavior

Fails to garbage collect unused nodes

The expected behavior

Should garbage collect

@faridsaid20 faridsaid20 added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

1 participant