NextJS app ran out of memory and crashed but metrics show memory usage not exceeded

I’d try raising the memory on the VM to 512 or 1024 to observe the next spike, see how far it goes without being OOM killed.

You could also enable swap, as outlined here: Swap memory - #2 by OldhamMade (if you don’t want to scale up your memory).

The same data (copied) can occupy different places at the same time, in memory (both kernel and user space). Your app’s structure will also use some space in memory, possibly more than the data itself.

These OOM kills are out of our control unfortunately. We try to use as less as possible from the init that we run in each VM (it shouldn’t be more than a few MBs).