In short: If you run OpenClaw as a service, its own installer already sets the heap limit for you; raising it with NODE_OPTIONS is a workaround, not a cure. On a 1 or 2 GB Raspberry Pi the real fix is more memory: swap at the very least, and for an always-on host a board with 4 GB or more. On a large machine, update first: several heap crashes reported on GitHub were bugs fixed in a later release.
| The message | FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory |
|---|---|
| Who sets the heap | openclaw gateway install, when no heap setting exists: 50% of capacity, 2048 MiB nominal floor |
| OpenClaw minimum (Pi page) | 1 GB RAM, 1 core, 500 MB disk, 64-bit OS; 2 GB+ recommended |
| Node advice for a 2 GiB machine | --max-old-space-size=1536, to leave room and avoid swapping |
| Lean profile for small machines | proposed in issue #202373, open: not shipped |
What the error means
Node.js runs OpenClaw on the V8 engine, which keeps most long-lived JavaScript objects in a region called the old space. The flag --max-old-space-size caps it. Node's documentation describes the behaviour near the cap: "As memory consumption approaches the limit, V8 will spend more time on garbage collection in an effort to free unused memory." When collection cannot free enough, the process aborts with the message above.
Two things follow. The crash is about the heap cap, not necessarily about free RAM: a machine with free memory can still hit a low cap. And the cap is not the whole process: OpenClaw's docs say "Old space is only part of V8's total heap, and neither is a limit on total process memory (RSS)." A Gateway can therefore be killed by the system for using too much memory overall, which is a different failure (on Docker, see exit code 137 and OOMKilled).
OpenClaw already sizes the heap when it installs the service
Most guides online tell you to add NODE_OPTIONS. Before you do, know what the project does itself. Its service docs: "For a managed Node Gateway without an existing heap setting, gateway install places --max-old-space-size in Node's launch arguments, before the entry script." The rule it applies:
| Rule | Value |
|---|---|
| Target | 50% of capacity |
| Nominal floor | 2048 MiB |
| Cap | the greater of 8192 MiB or 25% of capacity |
| Final cap | 75% of capacity, which "can put small-host budgets below the nominal floor" |
On a 1 GB board the arithmetic is the problem. Issue #200671 (a user report on a Raspberry Pi 4 with 1 GB, 511 MB of swap and an SD card, OpenClaw 2026.11.5) says it directly: "The 1 GB host is below the gateway's own 2048 MiB heap floor". No heap flag fixes a machine that has less memory than the heap the software is designed around.
On Linux, the same managed services and the official Docker image also default to MALLOC_ARENA_MAX=2 "to reduce glibc malloc arena fragmentation". If you wrote your own systemd unit or container command, you do not get either default: regenerating the service with openclaw gateway install is the documented path.
What users report on small boards
These are reports on OpenClaw's GitHub, by users and contributors, not statements from the maintainers and not our own measurements:
| Issue | Machine | What it says |
|---|---|---|
| #45440 (closed) | Raspberry Pi 4, about 2 GB | Heap crash after the 2026.3.12 upgrade. A contributor called a lower heap flag "workaround, not a true fix"; closed against the 2026.3.13 release, which fixed a memory blow-up. |
| #200671 (closed) | Raspberry Pi 4, 1 GB | Restart loop under systemd; the host is below the 2048 MiB heap floor. |
| #157791 (open) | ARM64, 3.7 GiB RAM, 2 GiB swap | About 138 s startup and steady memory near 1.32 GiB RSS. |
| #169797 (open) | single-CPU arm64 host | Peak memory from 706 MB to 1,815 or 1,938 MB between releases. |
| #202373 (open) | proposal | A "lean" profile for machines of about 2 GiB or less; idle RSS rose from 419 to 821 MiB between v2026.7.1 and main. |
The trend is plain: the Gateway has grown, and a lean mode for small machines is only a proposal so far. Buying a board for OpenClaw today, plan for the current memory use, not for a future profile.
The workaround: set the heap flag yourself
For a Gateway you start by hand, OpenClaw's troubleshooting page gives this form, "on a host with sufficient capacity":
NODE_OPTIONS="--max-old-space-size=16384" openclaw gateway runFor a custom supervisor or a Docker command, the same page says to place the flag "immediately after node, before the OpenClaw entry script, or set NODE_OPTIONS in that process or container's launch environment." The value 16384 is the docs' example for a large host, not a number to copy onto a Pi. Node's own advice for a small machine: "On a machine with 2 GiB of memory, consider setting this to 1536 (1.5 GiB) to leave some memory for other uses and avoid swapping."
In issue #45440 a commenter put Environment="NODE_OPTIONS=--max-old-space-size=2048" in the systemd unit. That buys headroom on a large machine. On a 2 GB board it lets the heap claim nearly all the RAM, which pushes the rest of the system into swap: the crash may stop, and the board becomes slow instead.
The fix on a 1 or 2 GB board: memory
OpenClaw's Raspberry Pi page rates a Pi 4 with 2 GB "OK" with the note "Add swap", a 1 GB Pi 4 "Tight" ("Possible with swap, minimal config"), and the Pi 5 with 4 or 8 GB "Best". Its documented setup adds a 2 GB swap file, "important for 2 GB or less". Its out-of-memory checklist: verify swap with free -h, disable unused services with sudo systemctl disable cups bluetooth avahi-daemon, and use API models only.
Swap is a stopgap. It turns a crash into slowness, and on an SD card it adds writes to a medium the same page says to avoid ("Use a USB SSD, SD cards are slow and wear out"; more on SD card corruption). If the board is a Pi 4 with 1 or 2 GB, the page on OpenClaw on a Raspberry Pi 4 covers what still runs. For a new purchase, a Pi 5 with 8 GB (Raspberry Pi 5 on Amazon) is above the 2048 MiB floor with room for the system; our estimates for each agent are on how much RAM an agent needs.
What to buy
- Raspberry Pi 5: take the 8 GB board for OpenClaw: above the Gateway's 2048 MiB heap floor with room left.
- USB 3 SSD: for swap and the system: OpenClaw's Pi page says to use a USB SSD rather than an SD card.
- Raspberry Pi SSD, M.2 2230: the NVMe route on a Pi 5, with the M.2 HAT+.
Shop links go through /go/ and open Amazon (amazon.fr in the EU and Switzerland, amazon.com elsewhere). As an Amazon Associate we earn from qualifying purchases. Your price does not change and no brand pays for a place on this page (disclosure). We write no price down: it moves, the shop shows today's.
Questions
Is NODE_OPTIONS=--max-old-space-size the fix for OpenClaw's heap error?
What heap size does OpenClaw use by default?
Can OpenClaw run on a 1 GB Raspberry Pi?
The error appears on a machine with plenty of RAM. Why?
Does adding swap fix it?
Sources
- OpenClaw docs, Gateway service (managed heap sizing), read on 21 November 2026.
- OpenClaw docs, Gateway service and process troubleshooting, read on 21 November 2026.
- OpenClaw docs, Raspberry Pi, read on 21 November 2026.
- Node.js docs, --max-old-space-size, read on 21 November 2026.
- OpenClaw issue #45440, OOM on Raspberry Pi 4 after 2026.3.12, read on 21 November 2026.
- OpenClaw issue #200671, restart loop on a 1 GB Raspberry Pi, read on 21 November 2026.
- OpenClaw issue #157791, startup and RSS on a small ARM64 machine, read on 21 November 2026.
- OpenClaw issue #169797, Gateway memory on a single-CPU host, read on 21 November 2026.
- OpenClaw issue #202373, lean Gateway profile for small machines, read on 21 November 2026.
- OpenClaw issue #186739, cold start heap exhaustion, read on 21 November 2026.