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

**URL:** <https://community.fly.io/t/nextjs-app-ran-out-of-memory-and-crashed-but-metrics-show-memory-usage-not-exceeded/7250>\
**Category:** Questions / Help\
**Created:** [September 19, 2022, 7:01am UTC](https://community.fly.io/t/nextjs-app-ran-out-of-memory-and-crashed-but-metrics-show-memory-usage-not-exceeded/7250 "2022-09-19T07:01:30Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![jerome](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/jerome/32/17_2.png) [@jerome](https://community.fly.io/u/jerome)\
**Post date:** [September 19, 2022, 5:56pm UTC](https://community.fly.io/t/nextjs-app-ran-out-of-memory-and-crashed-but-metrics-show-memory-usage-not-exceeded/7250/4 "2022-09-19T17:56:45Z")

</div>

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](https://community.fly.io/t/swap-memory/2749/2) (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).

---

_[View the full topic](https://community.fly.io/t/nextjs-app-ran-out-of-memory-and-crashed-but-metrics-show-memory-usage-not-exceeded/7250)._
