# GitHub Actions out of memory: exit code 137 and heap errors

A private repository's runner has 8 GB, shared by every worker and service the job starts. Here is how to find what used it, and how to fix it.

November 8, 2026, by Supercorp.

A GitHub Actions job that runs out of memory rarely says so plainly. The step ends with `Process completed with exit code 137`, or the log stops at `Killed`, or Node prints `FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory`, or Java throws `java.lang.OutOfMemoryError: Java heap space`. All of them mean the job asked for more memory than it could have. Here is how much a runner has, how to find what used it, and how to fix it.

## How much memory a runner has

From GitHub's [runner reference](https://docs.github.com/en/actions/reference/runners/github-hosted-runners) and [larger runners reference](https://docs.github.com/en/actions/reference/runners/larger-runners):

| Runner | CPUs | Memory |
|---|---|---|
| Standard Linux, Windows or Arm, private repository | 2 | 8 GB |
| Standard Linux, Windows or Arm, public repository | 4 | 16 GB |
| `ubuntu-slim` | 1 | 5 GB |
| macOS on Apple M1 (`macos-latest`) | 3 | 7 GB |
| macOS on Intel | 4 | 14 GB |
| Larger runner, 4 to 32 cores | 4 to 32 | 4 GB for each core |
| Larger runner with a T4 GPU | 4 | 28 GB |

So the same job can pass in a public repository, with 16 GB, and run out in a private one, with 8.

## What exit code 137 means

An exit code above 128 means the process was ended by a signal: 137 is 128 + 9, and signal 9 is `SIGKILL`. A process does not send that to itself. On a runner it almost always comes from the Linux kernel's out-of-memory killer, which picks the process using the most memory and ends it when the machine has none left. That is why the log stops mid-line, with no error of the program's own.

Heap errors are different: there the program itself stopped at a limit it was given (Node's or Java's heap), while the machine may still have had memory to spare.

## Find what used it

Add a step that runs when the job fails:

```yaml
- name: Memory
  if: failure()
  run: |
    free -h
    sudo dmesg | grep -i -E 'killed process|out of memory' || true
```

`dmesg` names the process the kernel killed and how much memory it held. To see how memory grows while the job runs, start a monitor in an earlier step:

```yaml
- name: Watch memory
  run: (while true; do echo "$(date +%T) $(free -m | awk 'NR==2 {print $3}') MB used"; sleep 10; done) &
```

## Fixes

### Run fewer things at once

Most test runners start one worker per CPU, or close to it, and every worker is a process with memory of its own. Five workers that need 2 GB each do not fit in 8 GB. Each tool has its own setting:

| Tool | Fewer workers |
|---|---|
| Jest | `--maxWorkers=2` |
| Vitest | `--maxWorkers=2` |
| Playwright | `--workers=2` |
| pytest-xdist | `-n 2` |
| Gradle | `--max-workers=2` |
| Cargo | `--jobs 2` or `CARGO_BUILD_JOBS=2` |
| make | `-j2` |

Services count too: a Postgres, a Redis and a browser started by the job share the same memory.

### Give Node the heap it needs, and no more

Node stops at its heap limit with `JavaScript heap out of memory` even when the machine has memory left. Raise the limit with `--max-old-space-size`, in MiB. [Node's documentation](https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-mib) suggests leaving room for the rest of the machine: "On a machine with 2 GiB of memory, consider setting this to 1536 (1.5 GiB)". On an 8 GB runner:

```yaml
env:
  NODE_OPTIONS: --max-old-space-size=6144
```

Setting it higher than the machine's memory turns a heap error into exit code 137: the kernel ends the process instead.

### Give the JVM its heap

For Gradle, set `org.gradle.jvmargs=-Xmx4g` in `gradle.properties`; for Maven, `MAVEN_OPTS=-Xmx4g`. As with Node, the heap and everything else running must fit in the runner's memory together.

### Keep the swap

GitHub's runners come with a swap file, which lets a job that briefly needs more than the machine has finish, slower. The [free-disk-space](https://github.com/lumbroso-commons/free-disk-space) action leaves it alone by default for that reason: removing it "can kill a job under memory pressure with no error pointing back here".

### Split the job

Work that runs side by side in one job can run in separate jobs, each with a machine of its own. A [matrix](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/run-job-variations) and your test runner's shard flag do it:

```yaml
strategy:
  matrix:
    shard: [1, 2, 3, 4]
steps:
  - run: npx playwright test --shard=${{ matrix.shard }}/4
```

### Use a machine with more memory

On GitHub, memory comes with cores: a larger runner has 4 GB for each, so 32 GB means the 8-core runner at $0.022 a minute, against $0.006 for the standard one. Larger runners need a Team or Enterprise Cloud plan.

## With SuperCI

SuperCI, which we make, runs GitHub Actions jobs on fresh machines in your own AWS, Cloudflare or Modal account. Memory is asked for apart from CPUs:

```yaml
jobs:
  build:
    runs-on: superci/cpu=4/ram=32
```

A 4-CPU, 32 GB spot machine (r8a.xlarge) was $0.075 an hour in us-east-1 on 8 November 2026, about $0.0012 a minute for the machine, so a job that needs memory does not have to pay for cores it cannot use. [Labels and machines](/docs/labels) lists every size a label can ask for, and [Faster tests](/docs/faster-tests) how to use the CPUs you have.

Related: [No space left on device in GitHub Actions](/blog/github-actions-no-space-left-on-device), and [every GitHub Actions limit in one place](/blog/github-actions-limits).
