-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Rendering just gets slower over time #4383
Comments
Hmm, that's odd! Mind trying something like
Also try that with requestIdleCallback and setTimeout. |
Just tried it, the same problem still seems to occur using |
For me it works correctly on both FF and Chrome 😅 EDIT: you didn't do what is in the code-snippet though 😅 |
What do you mean? I put that code snippet in and tried all the variations. Then I removed the snippet, so that's why it's not there when you click the link. |
Gotcha, the reproduction changed all the time in a few different ways 😅 either way mind doing
as it might just be prefresh holding onto vnode refs - in my tests this fixed it |
I just tried that as well-- it does seem to speed things up a bit, but by the time it reaches 1000 it's definitely slowing down. |
Could you do a memory dump because for me there's no more leak with that disabled |
Sure, I included 3 here: snapshots.zip |
if i understand the code correctly, then every click on the button creates a new additionally, the |
This is correct yes! I didn't look at the new code, the first version made sense as it just called setCount 1000 times 😅 |
I modified it to count up infinitely, you only need to click it once. There's definitely a leak not related to the |
preact-problem.mp4You can see it starts extremely fast, but by the time it reaches 1000 it's crawling. |
Aha, I disabled Preact Devtools and it seems the memory leak goes away. My bad for not mentioning I had that enabled, I forgot about it :( Curious what's causing it there though. |
Both prefresh as well as the dev-tools hold onto VNodes, we are probably running into some scenario where we fail to cut the link of i.e. |
CC @marvinhagemeister just so you're aware of this |
Will close out this issue now as we're aware of this issue in prefresh/devtools but those are also just for development. Most of the ESM HMR tools have a fundamental memory leak vitejs/vite#14438 - we might be able to circumvent some of it with i.e. preactjs/prefresh#545 but it will always be there in some way |
Describe the bug
It seems that as time goes on and things get rendered repeatedly, performance just slows down to the point where rendering takes much, much longer than it did at the start. I experienced this in one of my projects, and when I switched to React, the performance issue went away, which implies it's Preact-specific.
To Reproduce
https://codesandbox.io/p/devbox/preact-bug-cr5gfc?file=%2Fsrc%2FApp.tsx%3A21%2C1
Steps to reproduce the behavior:
Press Re-render 1000 times to do some re-rendering. At first it's quite fast, and then slowly but surely it bogs down to the point where it's taking a massive amount of time to increment the counter.
I can reproduce the bug in Firefox
124.0.2 (64-bit)
, but not on ChromiumVersion 124.0.6367.155 (Official Build) snap (64-bit)
Expected behavior
Performance should remain at the same level as when the app starts up. This seems like a pretty severe issue to me.
The text was updated successfully, but these errors were encountered: