GitHub Actions running out of memory
Published on August 27, 2025 | Written by Andreas
Is your GitHub Actions job failing with a cryptic error message? If you’ve seen your build crash unexpectedly, it might not be a problem with your code but with the environment it’s running in. The GitHub-hosted runners that power your workflows have finite memory—typically 7 GB for private repositories. For many modern build processes, that’s simply not enough.
Out-of-memory issues are a common and frustrating cause for build failures on GitHub Actions.
Problem
If your build log contains error messages like the ones below, memory is the likely culprit. The most telling sign is exit code 137, which indicates the operating system forcefully terminated your process (SIGKILL) to prevent system instability.
JavaScript heap out of memory
Java.lang.OutOfMemoryError: Java heap space
Couldn't allocate enough memory
Error: The process '/usr/bin/python3' failed with exit code 137
Killed process
runtime: out of memory: cannot allocate 16384-byte block
The standard GitHub-hosted runners are powerful, but their resources are limited. As you can see in the table below, runners for private repositories get less than half the RAM of those for public ones on Linux and Windows, which can cause builds that pass in public forks to fail in your private environment.
OS | Private Repository | Public Repository |
---|---|---|
Linux | 7 GB | 16 GB |
Windows | 7 GB | 16 GB |
macOS (Intel) | 14 GB | 14 GB |
macOS (M1) | 7 GB | 7 GB |
This memory constraint makes it common for jobs to fail, especially complex builds in private repositories.
Solution
So, how do you give your GitHub Actions jobs more memory? Let’s explore two effective solutions.
First, use large runners provided by GitHub.
- Requires a GitHub Team or GitHub Enterprise Cloud plan.
- Large runners provide up to 384 GB memory.
- GitHub charges about $0.001 per GB memory and minute.
The following table shows an excerpt of large runner pricing.
OS | CPU cores | Memory | $/min |
---|---|---|---|
Linux | 2 | 8 GB | $0.008 |
Linux | 4 | 16 GB | $0.016 |
Linux | 8 | 32 GB | $0.032 |
Linux | 16 | 64 GB | $0.064 |
Linux | 32 | 128 GB | $0.128 |
Linux | 64 | 256 GB | $0.256 |
Linux | 96 | 384 GB | $0.384 |
While powerful, the cost of large runners can add up quickly, which leads us to a more flexible and cost-effective alternative.
Second, use HyperEnv to deploy self-hosted GitHub Actions runners on AWS with ease. Doing so allows you to choose from a variety of virtual machines with up to 768 GB memory.
HyperEnv consists of the following building blocks as illustrated in the following figure.
- API Gateway
- Lambda function
- Step Functions state machine
- Lambda function
- EC2 instances
The solution is easy to install and requires minimal maintenance. Get started in four simple steps.
- Create AWS Marketplace subscription
- Launch with CloudFormation
- Install GitHub app
- Modify GitHub workflow to switch from GitHub-hosted to HyperEnv runner