Memory leaks
Bug report
Describe the bug
We have some problem on our server. After some time of execution we have an out of memory error on our 3Go AWS server. So I tried to log on my computer. I launch refresh of the home page every 5 seconds to see if the memory increase. Here is the memory evolution :

Here is the statistics just after nextjs server was launch :

Statistics on last snpashot

Any idea ? I don't know where to look for debugging this... Thanks !
System information
- OS: macOS
- Browser (if applies): Chrome
- Version of Next.js: 10.13.0
- NextJS: 8.0.0
- react-apollo: 2.4.1
- jss: 10.0.0-alpha.10
Any idea ? I don't know where to look for debugging this...
It's pretty much impossible to say without having a reproduction.
Try disabling JSS Not sure what you used, but some JSS implementations in app and document were leaky
Maybe it comes from here : https://github.com/apollographql/react-apollo/issues/2126
When I looked into comparaison between snapshots, maybe it comes from apollo :

Maybe it is, please provide a full reproduction otherwise it'll still be hard to track down from our side 🙏
@Yzrsah Hey you mentioned that JSS had some leaky implementations in app and document. I'm seeing a memory leak that might be related to JSS, do you have any info on what implementations were leaky? I'm using Material UI.
Hi @Irrelon ! A lot of nextJs update since I posted this issue. I don't have any problem anymore but be sure to correctly implement Link component (with href and as) as it might cause some memory problems :)
@HeadFox Thanks for the info :)
I actually think I've fixed it about an hour after posting... and it was because I'd very stupidly hooked an event listener in the constructor of a component and put the de-hook in componentWillUnmount which of course doesn't run server-side. After putting a if (process && process.browser) in the constructor code where it executes the event listener hook I have (I think) solved the problem.
Essentially:
- It was my fault
- Don't make event listeners that are cancelled in react lifecycle methods on the server-side :p
We were facing memory leaks with a similar configuration as mentioned above and we identified the problem layed in our SSR configuration. After passing the ssrMode property in the ApolloClient config everything works fine.
see here: https://www.apollographql.com/docs/react/features/server-side-rendering/#server-initialization
We have some problems with our server. After some time of execution, we have an out of memory error on the server.
So I tried to log on to my computer. I launch the refresh of the Search page every 5 seconds to see if the memory increase.
Here is the memory evolution :

So the conclusion is the bigger the size of user bigger the memory usage ultimately it will slow down the application or affect application performance please provide a full reproduction
Hi @Irrelon ! A lot of nextJs update since I posted this issue. I don't have any problem anymore but be sure to correctly implement Link component (with href and as) as it might cause some memory problems :)
Do you know why this would cause memory issues? On our next.js app we have a custom link button that utilizes the next.js Link component but we aren't using as with href or passHref. We're seeing a huge memory leak issue and this custom link component is our most widely used component.
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.