On this page

The OpenClaw Out of Memory Crash: What Causes It and How to Fix It

You opened a terminal, ran a basic OpenClaw command, and got this:

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

Or your Gateway just stopped responding with no error at all, and your system logs tell the story instead. Either way, the agent is down and the fix depends entirely on which type of OOM you are dealing with.

This guide covers the three confirmed causes of OpenClaw out of memory crashes, how to identify which one you have, and what to do about each one.

What Causes OpenClaw Out of Memory Crashes?

There are three distinct causes. They produce similar symptoms but have different fixes.

  • Cause 1: A version regression introduced a JavaScript heap memory leak.
  • Cause 2: The OS is killing the Gateway process because the host machine runs out of RAM.
  • Cause 3: The memory indexer is firing too many parallel embedding requests against large workspaces.

Identifying which cause you have takes about two minutes and determines everything that follows.

How to Diagnose Which OOM You Have

Is the Crash Happening on Basic CLI Commands?

Run this:

openclaw --version

If that command itself crashes with a JavaScript heap out of memory error, you have a version regression issue. This is confirmed behavior on OpenClaw version 2026.3.12, which introduced a memory leak in core module loading. It affects all CLI commands on Ubuntu and Linux. The fix is a downgrade.

Is the Crash Happening After Hours of Running?

If the Gateway runs fine initially but crashes after several hours, check your system logs:

journalctl -k | grep -i "oom|killed"
dmesg | grep -i "oom|killed"

If you see OOM kill entries, the host machine ran out of RAM and the OS terminated the Gateway process. This is infrastructure-level, not a bug in your OpenClaw version. A GitHub issue filed against v2026.4.5 confirmed the Gateway reaching 1.5GB RAM and 47% CPU within hours of running, causing repeated crashes.

Is the Crash Happening During Memory Indexing?

If you see this error when running openclaw memory index --force:

Memory index failed (main): fetch failed

And you have a large workspace with many Markdown files, you have hit a confirmed indexer bug (GitHub issue #56427). The indexer fires all embedding batches in parallel with no concurrency limit, which causes rate limiting failures. After two failures, batch mode is permanently disabled until you restart the Gateway.

Fix 1: Version Regression OOM (2026.3.12 Memory Leak)

If basic CLI commands are crashing, downgrade immediately:

npm uninstall -g openclaw
npm install -g [email protected]

Confirm the downgrade worked:

openclaw --version
openclaw gateway status

Version 2026.3.11 is the last known stable version before this regression. The memory leak is in core module loading and initialization, which is why even openclaw doctor crashes before it can diagnose anything. Monitor the OpenClaw GitHub releases page for a patched version before upgrading again.

Fix 2: OS-Level OOM Kill (Gateway RAM Exhaustion)

This fix has three parts, in order of impact.

Reduce cron concurrency first

Open your OpenClaw config and lower maxConcurrentRuns in the cron section. Heavy cron concurrency is the most common cause of gateway RAM growth on shared VPS instances.

Disable channels and plugins one at a time

If you run multiple channels (Slack, Telegram, WhatsApp, iMessage simultaneously), disable them one by one and monitor memory after each change. This identifies which channel integration is the RAM consumer.

Move the Gateway to its own VPS instance

If you are running OpenClaw alongside other services on a shared host, the Gateway competes for the same RAM pool. A dedicated instance with 2GB or more allocated exclusively to the Gateway resolves most sustained OOM kill situations.

Fix 3: Memory Indexer OOM on Large Workspaces

If you have 1,000 or more Markdown files in your workspace, the indexer will fire all embedding batches in parallel and hit rate limits. The confirmed workaround is to move non-essential files out of the memory directory before indexing:

# Move sessions, backups, and non-markdown content out of memory scope
mv ~/.openclaw/workspace/sessions/ ~/openclaw-backup/sessions/
mv ~/.openclaw/workspace/backups/ ~/openclaw-backup/backups/

After reducing the workspace scope, restart the Gateway and run:

openclaw memory index --force

If batch mode was already disabled by prior failures, the Gateway restart resets the failure counter. Monitor the indexing output and confirm it completes without rate limit errors before re-adding files.

How to Prevent These Crashes Going Forward

Set a Context Token Limit

OpenClaw’s context assembly is aggressive by default. If you do not set a ceiling, the context window fills up faster than expected, triggers compaction, and the compaction process itself consumes significant memory. Set maxContextTokens to 80% of your model’s context limit in your OpenClaw config.

Pin Critical Instructions

Mark instructions that must survive context compaction with [PINNED] tags in your SOUL.md and MEMORY.md. Pinned content is preserved when OpenClaw compresses older messages. Without pinning, compaction is lossy and the agent silently loses active working context mid-session.

Watch the Gateway Memory in Real Time

watch -n 5 'ps aux | grep openclaw'

This gives you a live view of Gateway memory consumption every five seconds. If RAM climbs steadily without a ceiling, you have a leak or a concurrency issue that will produce an OOM kill before the session ends.

The Managed Alternative: No OOM Configuration Required

The configuration work above is real, and it is ongoing. A new version can reintroduce a memory leak (as 2026.3.12 did), a cron job can quietly push the Gateway past its RAM ceiling, and a growing workspace will eventually hit the indexer’s concurrency limits again.

PAIO.claw is a managed OpenClaw hosting platform where the infrastructure layer, memory limits, Gateway configuration, and version management are handled for you. When OpenClaw ships a regression like the 2026.3.12 heap leak, PAIO does not push it. When the Gateway grows past safe memory thresholds, PAIO’s infrastructure manages the ceiling. Setup takes under 60 seconds and starts at $4 per month.

You can spend an afternoon tuning cron concurrency limits, monitoring RAM consumption, and rolling back versions when a new release breaks things. Or you can run the same agent without touching any of it.

Frequently Asked Questions

What causes the OpenClaw “JavaScript heap out of memory” error?

The most common cause is a version regression introduced in OpenClaw 2026.3.12, which introduced a memory leak in core module initialization. It makes basic CLI commands crash before any model or provider interaction occurs. The fix is downgrading to 2026.3.11 using npm install -g [email protected].

Why does my OpenClaw Gateway crash after running for a few hours?

This is an OS-level OOM kill, not a JavaScript heap error. The host machine runs out of available RAM and the OS terminates the Gateway process. Common triggers are high cron concurrency, running too many channels simultaneously, and sharing a VPS with other services. Check journalctl -k | grep -i "oom|killed" to confirm. The fix is reducing maxConcurrentRuns, disabling unused channels, or giving the Gateway a dedicated host.

Why does OpenClaw memory indexing fail with “fetch failed”?

This is a confirmed bug (GitHub issue #56427) in the memory indexer’s embedding batch process. The indexer fires all batches in parallel with no concurrency limit, which causes API rate limiting on large workspaces. After two failures, batch mode is permanently disabled until you restart the Gateway. Reducing workspace size by moving session and backup files out of the memory directory before indexing is the current workaround.

How do I stop OpenClaw from losing memory mid-session?

Set maxContextTokens to 80% of your model’s context limit to prevent aggressive context compaction. Add [PINNED] tags to critical instructions in SOUL.md so they survive compaction. For Docker deployments, mount a persistent volume so memory files are not lost between container restarts.

Does PAIO prevent OpenClaw out of memory crashes?

PAIO’s managed infrastructure handles Gateway memory configuration, version management, and update vetting, so version regressions like the 2026.3.12 heap leak do not reach your instance. The OOM configuration steps covered in this guide are part of what PAIO manages on your behalf, starting at $4 per month.

Join Our Community

Connect with other PaioClaw users, share tips, and stay up to date.