-
Notifications
You must be signed in to change notification settings - Fork 27
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
Memory is leaked when a component is updated - Simple Reproduction #473
Comments
Just in case the suspicion comes up, I am not actually updating the state with |
I gave this a go and limited the counter to 10000 iterations. From looking at the profiler tab memory seems to be freed correctly by Chrome when in incognito mode. But when DevTools is active it doesn't seem to free memory in the same way. Do you happen to have the DevTools bridge active? With DevTools: Without DevTools: |
Thank you @marvinhagemeister ! I included I didn't manually include the DevTools bridge in the reproduction app, but prompted by your hint, I looked into the generated source code and it seems that the Vite development server injects it:
When I build the reproduction app for production ( So should I learn from this that I shouldn't import |
Awesome, that narrows it down! I'd definitely count a memory leak as a bug and something to be addressed on the DevTools side of things. |
Great! Until this is fixed, is there a way to conditionally include the bridge (I mean preact/devtools) or, as an alternative, disable it based on some flag after it is loaded? |
If I import I should have realized this earlier, sorry for that. Fixing a leak that only occurs in development mode (or even only in combination with the Vite dev server, I don't know) is probably low priority. |
Describe the bug
Memory is leaked when a component is updated.
My Electron (happens in Chrome also, see below!) application has a progress display (status text showing transferred bytes, progress bar) which updates very often. As Electron has the V8 Memory Cage enabled since version 21, limiting the memory to a few gigabytes (they say 4 GB, but it is 3 GB in my tests), the application frontend goes away after a while (leaving an empty BrowserWindow).
After spending a lot of time tracking down this issue, I was able write a simple reproduction - see below - which fills up the memory very fast in Chrome (see Chrome DevTools -> Memory).
To Reproduce
Use a current version of Chrome.
Expected behavior
Memory usage should remain quite constant. It should definitely not lead to an out-of-memory error.
The text was updated successfully, but these errors were encountered: