- Newest
- Most votes
- Most comments
The issue you're experiencing with your Amplify build failing due to memory constraints is a common problem, especially with complex React applications.
To address your questions:
-
Yes, by default the Node process has a limited heap size that doesn't automatically use all available container memory. This is why you're seeing out of memory errors even on the Standard 8 GiB instance.
-
Adding
NODE_OPTIONS="--max-old-space-size=6144"to your amplify.yml would help, but may not completely solve the issue if your build is particularly memory-intensive. You can try setting this value, but be careful not to set it too close to the total available memory (8 GiB) as the system needs some memory for other processes. -
Additional tips to resolve this issue:
-
Upgrade your build instance: Amplify now offers larger build instances. You can upgrade to a Large instance (16 GiB memory, 8 vCPUs) or XLarge instance (72 GiB memory, 36 vCPUs) depending on your needs.
-
If using a larger instance, adjust your NODE_OPTIONS accordingly (e.g.,
--max-old-space-size=14000for the Large instance). -
Optimize your build cache configuration in amplify.yml. For Next.js applications, removing
.next/cache/**/*from cache paths has helped some users, though this may not apply directly to your CRA app. -
Consider splitting your build into smaller chunks if possible.
-
Review your application for memory leaks or particularly resource-intensive build steps.
The most straightforward solution would be to upgrade to a larger build instance, which you can configure through the Amplify console or using the AWS CLI.
Sources
Build container ran out of memory | AWS re:Post
Introducing Upgraded Build Instances on Amplify Hosting | Front-End Web & Mobile
get-app — AWS CLI 2.27.36 Command Reference
update-app — AWS CLI 2.27.36 Command Reference
answered a year ago
Relevant content
asked 2 years ago
asked 2 years ago
