High memory usage in deployed Next.js project

Hey there,

According to the issue on the next.js repo, there’s a memory leak from the event emitter. I bet most people run their next.js apps in serverless environment where they’re short-lived and recycled before they hit these issues? I’m not certain.

Can you try adding some swap memory to your machine until this is resolved upstream? Here’s a simple way to do it: Swap memory - #2 by OldhamMade

Adding swap won’t exactly help forever if there is a memory leak, it’ll just take longer before it runs out of memory.

As mentioned before, since Vercel runs on AWS Lambda, there are many differences, including the fact that the virtual machines are constantly being stopped and started, preventing the accumulation of leaked memory.

Looking at the next.js repository, there are a lot of memory leak issues, often without resolution / response.

I looked at apps v1 platform VMs and they seem to have the same discrepancy. I’m looking around a bit, but I’m not sure where it comes from. We’re passing in 256MiB to firecracker, I am sure of that. So the discrepancy is created somewhere else, either from firecracker or the kernel? Not sure.

1 Like