Next.js Discord

Discord Forum

Can't build app I've been working on after it uses 50GB RAM

Unanswered
Pinea posted this in #help-forum
Open in Discord
I've been making and building this app for over a couple of years now, but suddenly when I try to build it, Next build spikes to 54GB memory usage and gives up. Is there any way to debug why? I rebooted the device and the only thing I did was build - out of memory again

12 Replies

Updated to 16.4.6, and still get the same issue
It says "Creating an optimised production build" and completely stops
Even with next build -d I get no extra logs
❯ bun run build --experimental-debug-memory-usage
$ next build --experimental-debug-memory-usage
⚠ Memory debugging mode is enabled. Note: This will affect performance.
   - Heap snapshots will be automatically generated when the process reaches more than 70% of the memory limit and again when the process is just about to run out of memory.
   - To manually generate a heap snapshot, send the process a SIGUSR2 signal: `kill -SIGUSR2 5616`
   - Heap snapshots when there is high memory will take a very long time to complete and may be difficult to analyze in tools.
   - See https://nextjs.org/docs/app/building-your-application/optimizing/memory-usage for more information.
▲ Next.js 16.4.6 (Turbopack)
- Environments: .env
✓ Running next.config.ts took 63ms
- Experiments (use with caution):
  · serverActions

  Creating an optimized production build ...

  ***************************************
  Memory usage report at "Starting build":
   - RSS: 69.23 MB
   - Heap Used: 31.68 MB
   - Heap Total Allocated: 42.05 MB
   - Heap Max: 4192.00 MB
   - Percentage Heap Used: 0.76%
  ***************************************


  ***************************************
  Memory usage report at "periodic memory snapshot":
   - RSS: 31408.32 MB
   - Heap Used: 32.48 MB
   - Heap Total Allocated: 42.30 MB
   - Heap Max: 4192.00 MB
   - Percentage Heap Used: 0.77%
  ***************************************


  ***************************************
  Memory usage report at "periodic memory snapshot":
   - RSS: 56020.89 MB
   - Heap Used: 32.50 MB
   - Heap Total Allocated: 42.30 MB
   - Heap Max: 4192.00 MB
   - Percentage Heap Used: 0.78%
  ***************************************

error: script "build" exited with code 137
Can confirm this is - in fact - broken on previous versions too! At least as old as 16.4.0
It's also not fixed in 16.5.0-c.55
And magically after deleting .next, node_modules (which I'd already done both), and a bunch of cache folders.. it magically worked?
Nothing was done any differently
And on 16.4.6, which I tried already