Next.js Discord

Discord Forum

Dev server high memory usage - how best to debug

Unanswered
Florida Scrub-Jay posted this in #help-forum
Open in Discord
Florida Scrub-JayOP
Here's all the info:
- Dev server only, production is fine
- Memory usage is around ~700KB when the dev server starts
- As soon as a page is requested, memory usage spikes to 4-5GB
- We are a fully CSR app, with minimal bundle splitting (yikes, I know)
- After compiling, the message states that there are 12,000 modules (also yikes)
- Doing a heap profile of the dev server process only shows about ~700KB usage for some reason
- Profiling in MacOS with Instruments, I see a massive spike in memory allocations when the dev server starts, and it hangs onto that memory

If I wanted to even begin trying to figure out how to start tackling this, where should I start? What is grabbing on to all this memory - webpack? Is it the number of imports? Any guidance is appreciated.

4 Replies

Florida Scrub-JayOP
I was worried this would be the case. we're dealing with really high memory pressure on our memory-limited dev machines. i guess if there's no real way to beat next into submission and use less memory, we'll have to explore other avenues
the dev server is known to be not performant. it used to be slow, now it's a bit faster at the cost of higher memory usage. can't do much about it.
Florida Scrub-JayOP
understood. thanks for the context!