react: [DevTools Bug]: Consistent memory leak when refreshing on React + non-React websites.
Website or app
Repro steps
With Chrome version 121.0.6167.184 (Official Build) (arm64)
React dev tools: 5.0
- Created from revision 993c4d003 on 12/5/2023.
Repeatedly refreshing https://google.com
continually leaks memory.
With React Dev Tools
Some memory is retained temporarily between refreshes, but notably forcing GC (the trashcan button), never shrinks + each subsequent refresh monotonically increases memory overhead.
https://github.com/facebook/react/assets/5288805/1cc1b7b4-06c5-4ec9-aaf4-e65c8e40dffc
Without React Dev Tools
Forcing GC without react dev tools drops the memory footprint from ~100MB to ~10MB instantly.
https://github.com/facebook/react/assets/5288805/29beb02b-1c16-4ec4-91f0-b732f992b72e
Other debugging:
Went down a massive rabbithole of Chrome version bisection (memory between refreshed started to be retained a bit longer with this V8 GC change), but it always GC’d correctly when being forced: https://chromium.googlesource.com/v8/v8/+/7477604415624e2f60000194f766e2f404e02fed.
Other notes:
- This was in incognito mode without any other extensions enabled
- Happy to provide heap snapshots (it appears that retained memory is mostly
closure
+compiled
code) + hopefully this should be simple to repro.
How often does this bug happen?
Every time
DevTools package (automated)
No response
DevTools version (automated)
No response
Error message (automated)
No response
Error call stack (automated)
No response
Error component stack (automated)
No response
GitHub query string (automated)
No response
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Reactions: 1
- Comments: 16 (5 by maintainers)
Thanks for reporting this and recording a demo, I will try to triage this early next week, hopefully shipping a fix soon. If someone is already triaging this, feel free to open a PR and mentioning this issue.
Also cannot reproduce anymore 😬 (same chrome version as @hoxyq ).
I’m slightly concerned that this might reappear unless we can pinpoint the Chromium commit that might have changed the behavior here…
Just wondering, how’d you install React DevTools in incognito?
Chrome Version 122.0.6261.129 (Official Build) (64-bit) Can’t reproduce. Refreshes accumulate MB infinitely, but waiting for ~5 seconds or pressing “Collect garbage” flushes everything instantly down to ~10 MB.
Firefox Version 123.0.1 (64-bit) Measured private window in
about:processes
with and without React Dev Tools - memory behavior seems to be the same. Was able to instantly free up memory inabout:memory
withFree memory - GC
on both occasions. From ~500 MB to ~210 MB instantly.I guess not a Chromium or Firefox issue then if both browsers suddenly behave properly, or it can be?
There’s an
Allow in Incognito
switch in theDetails
of any Chrome extension.