openclaw - 💡(How to fix) Fix Critical: Gateway Memory Leak — RSS grows from 350MB to 15.5GB over days, causing repeated OOM crashes

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

The OpenClaw gateway process suffers from a severe memory leak. RSS grows from ~350 MB at startup to 15.5 GB over 2-3 days of normal use, eventually causing the process to be killed by the OS OOM killer. This triggers repeated launchd-handoff restart cycles.

Error Message

| 2026-06-04 | 6 | Including one I/O error (Bootstrap failed: 5: Input/output error) |

Crashes Produce No Error Logs

The gateway error log (gateway.err.log) has no entries since May 21. The process dies silently — consistent with OOM kill or Node.js heap exhaustion with no chance to write diagnostics. 2. Self-protection: Add a --max-old-space-size default (e.g., 4096 MB) to the gateway Node.js process to trigger a clean GC/OOM error before the OS OOM killer.

Root Cause

  1. Memory growth is monotonic: RSS increases steadily over days, never decreases.
  2. No automatic recovery: The process dies silently, leaving only launchd to restart it.
  3. Plugin state accumulation suspected: With claw-mem (in-memory index, search cache) and claw-ctx (token caches, session state, drift alerts) loaded, the gateway never purges accumulated state between sessions.
  4. No heap limit configured: The gateway Node.js process has no --max-old-space-size flag. On an 8 GB machine, this means it can consume all available RAM before being killed.
  5. Physical RAM saturation: 15.5 GB RSS on an 8 GB machine causes heavy swapping, degrading the entire system before the OOM kill.

Fix Action

Fix / Workaround

A prior separate issue (May 21) caused a startup crash loop: the claw-mem plugin manifest was not found at the configured path. This was fixed by rebuilding the plugin. The two issues are independent but compound: the startup crash prevents recovery after the OOM kill.

Code Example

PID 19893  RSS: 15,513 MB  CPU: 89.7%  (openclaw-gateway)
PID 40226  RSS:    201 MB  CPU:  0.0%  (openclaw-tui, running 2+ days)

---

PID 19926  RSS:    350 MB  CPU:  0.3%  (openclaw-gateway)
PID 40226  RSS:    197 MB  CPU:  0.0%  (openclaw-tui)
RAW_BUFFERClick to expand / collapse

Summary

The OpenClaw gateway process suffers from a severe memory leak. RSS grows from ~350 MB at startup to 15.5 GB over 2-3 days of normal use, eventually causing the process to be killed by the OS OOM killer. This triggers repeated launchd-handoff restart cycles.

Environment

  • OpenClaw version: 2026.6.1 (2e08f0f)
  • Node.js: v22.22.0
  • OS: macOS 20.6.0 (Big Sur), x64
  • System RAM: 8 GB
  • Plugins loaded: claw-mem (v6.15.0), claw-ctx (v5.2.0) — custom local plugins

Evidence

Before Restart (memory leak peak)

PID 19893  RSS: 15,513 MB  CPU: 89.7%  (openclaw-gateway)
PID 40226  RSS:    201 MB  CPU:  0.0%  (openclaw-tui, running 2+ days)

After Restart (immediately)

PID 19926  RSS:    350 MB  CPU:  0.3%  (openclaw-gateway)
PID 40226  RSS:    197 MB  CPU:  0.0%  (openclaw-tui)

The gateway dropped from 15.5 GB to 350 MB after a single restart, confirming a memory leak in the long-running process, not a configuration or disk-space issue.

Restart/Crash Frequency

From ~/.openclaw/logs/gateway-restart.log, launchd-handoff restarts (process died → launchd auto-restarted):

DateCountPattern
2026-06-046Including one I/O error (Bootstrap failed: 5: Input/output error)
2026-06-0598 crashes within a 2-hour window
2026-06-097Before manual restart, 7 crashes between 00:41 and 03:33 UTC

Crashes Produce No Error Logs

The gateway error log (gateway.err.log) has no entries since May 21. The process dies silently — consistent with OOM kill or Node.js heap exhaustion with no chance to write diagnostics.

Analysis

  1. Memory growth is monotonic: RSS increases steadily over days, never decreases.
  2. No automatic recovery: The process dies silently, leaving only launchd to restart it.
  3. Plugin state accumulation suspected: With claw-mem (in-memory index, search cache) and claw-ctx (token caches, session state, drift alerts) loaded, the gateway never purges accumulated state between sessions.
  4. No heap limit configured: The gateway Node.js process has no --max-old-space-size flag. On an 8 GB machine, this means it can consume all available RAM before being killed.
  5. Physical RAM saturation: 15.5 GB RSS on an 8 GB machine causes heavy swapping, degrading the entire system before the OOM kill.

Impact

  • Critical: Gateway becomes unresponsive or crashes multiple times per day
  • Intermediate crashes interrupt ongoing conversations and tool operations
  • Repeated restart cycles generate noise in stability logs
  • Degrades confidence in OpenClaw as a reliable long-running agent platform

Suggested Fixes

  1. Root cause: Investigate and fix memory leaks in the gateway process, particularly around plugin lifecycle (plugin state not released between sessions) and internal caches (unbounded growth).
  2. Self-protection: Add a --max-old-space-size default (e.g., 4096 MB) to the gateway Node.js process to trigger a clean GC/OOM error before the OS OOM killer.
  3. Health monitoring: Implement an RSS-based self-restart (e.g., if RSS > 4 GB, gracefully restart). This is a pragmatic safeguard even after the leak is fixed.
  4. Periodic restart: Consider an optional --auto-restart-interval flag (e.g., daily at 3 AM) for production deployments.

Steps to Reproduce

  1. Start openclaw gateway with memory/caching plugins loaded
  2. Use the gateway normally over 2-3 days (send messages, perform tool calls)
  3. Monitor RSS with ps -o pid,rss,comm
  4. Observe RSS grow from ~350 MB to 10+ GB
  5. Eventually the process is killed by the OS

Additional Context

A prior separate issue (May 21) caused a startup crash loop: the claw-mem plugin manifest was not found at the configured path. This was fixed by rebuilding the plugin. The two issues are independent but compound: the startup crash prevents recovery after the OOM kill.


Submitted via gh CLI by Jarvis (Peter Cheng's assistant)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING