-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[SSR] Controllers are not garbage collected correctly #778
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
Comments
@aleclarson I think the problem is that When I add Thank you |
Running into the same issue here, our Next.js app server ran into OOM issues constantly because of this, we were using |
@aleclarson is there anything I can try to solve this issue? I know you are quite busy with v9 so maybe some hints :) Thank you |
Haven't had time to dig into this yet. You can use issuehunt.io to put a bounty on this issue if it's a blocker for you. |
@aleclarson Thanks, I'll wait for new beta :) I can see you moved controllers Set inside FrameLoop. Maybe it will help. |
@DeviousM I'm not using react-spring with SSR anywhere right now. Have you tried with the latest canary? |
Yup, I've just tried the latest canary and got this error:
And the
I'll provide a minimal reproduction case in a moment. |
Alright, @aleclarson, I've created a repo that allows you to clone it and run the heap test locally: https://github.com/DeviousM/react-spring-ssr-issues To reproduce the issue clone the project, then Then to simulate some load on the server download a tool like Let me know if you have any more questions about my example. |
That's because the function signature of I gave @RafalFilipek's repro a try with both After 10k requests, it went from 5.2MB to 44.5MB when using You can see my fork of the repro here: https://github.com/aleclarson/repro/commits/react-spring-778 |
Oh, alight! Let me try it then, I'll report back with results. |
Yep, it fixes the memory leak! Thanks! BTW - is there a list of all of the API's that have changed? Because there are quite few places where my app now looks bad (ie. Trail now kind of broke) + is there a way to get index of the item in the new Transition implementation? |
Hi, I've just tested my example with @aleclarson I think we can close this issue. I'll monitor new versions actively :) Thank you! |
Yup, on our production build the SSR server didn't grow almost at all. I agree that we could close the issue, though shouldn't we wait with it until the v9 or at least a new beta is released? Because currently it's still a case for normal |
Not yet. I'll write one up when we're closer to v9 being released.
Could you ask these questions separately in our Spectrum community? Thanks 👍 |
Hi, |
With the cause being known that controllers within https://github.com/react-spring/react-spring/blob/66087e18b64d6c6d5fd75f6d84e85ed59714769d/src/animated/FrameLoop.ts#L6 are not being cleaned up, what would we need to get this fixed? I'm up for helping out, but I'm not 100% certain where I should clean this up? Either the Controller class should remove itself when being stopped/destroyed or wherever they are being created they should be cleaned up. Any help from the maintainers would be great, I'd be happy to help out on a weekend of mine, should I contact you via spectrum? |
If anyone has time, please try with More info: #985 |
|
@topaxi v9 is more stable than v8 at this point. I recommend migrating to it and reporting any bugs you may find. I'll fix 'em up real quick ;) |
closing due to inactivity, looks like it was fixed in rc3. please use discussions or discord if you want more help or please consider creating a PR if you want to add a feature 😄 |
Bug report
Describe the bug
Hi,
I found this bug in my Next.js app, but we think it's not related to NextJS itself but rather SSR in general.
Let's go straight to example:
To Reproduce
yarn install
yarn build
yarn start
This command will start production version of application with
--inspect
flag to enable NodeJs debugger.[http://localhost:3000](http://localhost:3000)
in ChomeThis will open Dedicated NodeJS debugger.
Memory
tab, selectHeap Snapshot
and clickTake Snapshot
. You will get something like this:Now it's time to make some requests. I'm using autocannon, but you can use any tool like
ab
.Now you can take second snapshot. It should be much bigger:
After 4K requests you will see that there is a lot of allocations in
array
part. For some reason there are many allocations ofController
class fromreact-spring
. I have no idea why.It looks like new Controller class is created for each request, but old instances are not garbage collected. (this and this lines?)
Now let's compare snapshots in this same application but without
getInitialProps
in_app.js
- no SRR.After 10K request you will get something like this:
Snapshot 1
- afteryarn start
Snapshot 2
- after 10K reqSnapshot 3
- afterGC
System information
9.0.2
,9.0.3
8.0.27,
9.0.0-beta.31
16.8.6
Thank you
The text was updated successfully, but these errors were encountered: