Skip to content

Critical: Gateway Memory Leak — RSS grows from 350MB to 15.5GB over days, causing repeated OOM crashes #91588

Open

Description

@petercheng

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):

Date Count Pattern
2026-06-04 6 Including one I/O error (Bootstrap failed: 5: Input/output error)
2026-06-05 9 8 crashes within a 2-hour window
2026-06-09 7 Before 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)

Activity

  1. clawsweeper commented on Jun 9, 2026

    @clawsweeper
    Contributor

    Codex review: this still needs some work.

    Summary
    Keep open: later official-release reports document memory-related Gateway outages, and the merged retention repairs do not establish resolution of those workloads.

    Reproducibility: no. high-confidence current-main reproduction is established: the release measurements and crash traces are concrete, but neither source inspection nor the linked repairs proves the remaining workloads fixed.

    Next step
    Profile one offered workload on pinned current main with worker coverage and process-tree memory measurements to identify the remaining allocation owner.

    Review details

    Best possible solution:

    Repair the demonstrated allocation owner while preserving session data, active work, and bounded worker reuse.

    Do we have a high-confidence way to reproduce the issue?

    No high-confidence current-main reproduction is established: the release measurements and crash traces are concrete, but neither source inspection nor the linked repairs proves the remaining workloads fixed.

    Is this the best way to solve the issue?

    Blanket spread replacements, larger heap caps, and scheduled restarts do not identify the remaining allocation owner; worker-aware profiling should precede another lifecycle change.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • No matched affected workload establishes continued failure or sustained recovery on current main.
    • The discussion combines plugin retention, worker heaps, native allocation failures, and child-process accumulation without a verified common cause.

    Codex review notes: model internal, reasoning medium; reviewed against 863839d03293.

    Label changes

    Label changes:

    No label changes.

    Label justifications:

    • P0: Reported official-release memory exhaustion repeatedly aborts or OOM-kills the core Gateway and interrupts service.
    • impact:crash-loop: Memory exhaustion causes repeated supervised process restarts and periods of Gateway unavailability.
    Evidence reviewed

    What I checked:

    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge; those execution lanes are retired.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    Reviewed October 27, 2026, 4:58 AM ET / 08:58 UTC.

  2. added
    P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.
    impact:crash-loopCrash, hang, restart loop, or process-level availability failure.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    on Jun 9, 2026
  3. petercheng commented on Jun 9, 2026

    @petercheng
    Author

    Update: Bug persists — gateway still crashing every 3-4 hours

    Since filing this issue, we've attempted multiple mitigation steps, but the root cause remains unaddressed.

    Timeline Today (June 9, 2026)

    Time (UTC) Event
    00:41–03:33 7 auto-restarts (launchd-handoff, process dying silently)
    03:35 Manual restart — RSS dropped from 15.5 GB → 350 MB
    03:35–06:56 Gateway ran ~3.5 hours, RSS grew from 350 MB → 500+ MB
    06:56 Crashed again (PID 19926 → 24849)
    ~07:00 Another restart (PID 24849 → 24902, now running 37 min, already 503 MB)

    Reproducibility

    This is 100% reproducible. The gateway process cannot survive more than 4 hours under normal usage (a few plugin calls, session operations). The memory grows monotonically until the OS OOM killer or Node.js heap exhaustion terminates the process silently — no error logs, no stability bundle.

    Impact on User Experience

    Critical: A personal AI assistant that cannot stay alive for more than a few hours is fundamentally broken from a user's perspective. Every crash disrupts ongoing conversations, loses context, and requires manual intervention. This is not a corner case — it happens every single day, multiple times per day.

    Attempted Workarounds (all failed to fix the root cause)

    1. Rebuilt all plugins (claw-mem, claw-ctx) from source
    2. Fixed plugin manifest paths
    3. Cleaned tmp/cache directories (192 MB → 38 MB)
    4. Restarted gateway processes
    5. Removed "type": "module" from claw-mem package.json (ESM/CJS conflict fix)
    6. Added moduleResolution: "node10" to tsconfig.json

    None of these stopped the memory leak. The process still grows from ~350 MB to 500+ MB within hours and dies.

    Request

    Please escalate this issue. A long-running agent platform must be able to run for days or weeks without crashing. The minimum viable fix would be:

    1. Root cause: Identify and fix the memory leak (likely in session state accumulation, plugin lifecycle, or internal caches)
    2. Self-protection: Add a --max-old-space-size default and an RSS-based health check with graceful restart before the OS OOM killer intervenes

    Environment (repeated for emphasis)

    • OpenClaw 2026.6.1 (2e08f0f)
    • Node.js v22.22.0
    • macOS 20.6.0, 8 GB RAM
    • Plugins: claw-mem v6.15.1, claw-ctx v5.2.0
  4. arthursoares commented on Jun 11, 2026

    @arthursoares

    Adding a corroborating data point from a different host, with native stack evidence that may help localize this.

    Environment: OpenClaw 2026.6.1 (2e08f0f), Node v22.22.3, Linux 6.8 LXC (16 cores, 24 GB), systemd user service, native Codex runtime (openai/gpt-5.5), 15 agents, Telegram channel.

    Symptom shape (matches OP): gateway RSS grows monotonically with uptime — ~685 MB at start → 1.9 GB by day 7. Unlike OP we run --max-old-space-size=6144, so no OOM crash; instead, by day ~7 the main JS thread pins at 100% user CPU with event-loop delays of p99 ≈ 8,000 ms (169 liveness warning lines in one day), making every channel reply queue for many seconds. A restart resets RSS to baseline and CPU to ~1%.

    Native stack samples (gdb batch bt against the live process while pinned; V8 symbols from the node binary):

    Sample A — repeatedly inside object-spread over a dictionary-mode object:

    v8::internal::OrderedHashSet::Add
    v8::internal::KeyAccumulator::AddKey
    v8::internal::(anonymous namespace)::CollectKeysFromDictionary<v8::internal::NameDictionary>
    v8::internal::KeyAccumulator::CollectOwnPropertyNames
    v8::internal::KeyAccumulator::CollectKeys
    v8::internal::JSReceiver::SetOrCopyDataProperties
    v8::internal::Runtime_CopyDataPropertiesWithExcludedPropertiesOnStack
    

    Sample B — scavenge GC churn driven by the same copying (allocation inside NameDictionary::New → JSObject::MigrateToMap):

    v8::internal::ScavengerCollector::CollectGarbage
    v8::internal::Heap::Scavenge
    ...
    v8::internal::HashTable<v8::internal::NameDictionary,...>::New
    v8::internal::JSObject::MigrateToMap
    v8::internal::Object::TransitionAndWriteDataProperty
    

    Interpretation: Runtime_CopyDataPropertiesWithExcludedPropertiesOnStack is the runtime path for JS object spread/rest with exclusions (const {x, ...rest} = obj / {...obj}), and CollectKeysFromDictionary means the source object has degraded to dictionary mode — i.e. a very large, long-lived key set. Some per-event hot path (the pinning correlates with active model_call / embedded_run stream processing in our liveness logs) appears to shallow-copy a state object that accumulates keys for the lifetime of the gateway. Early in uptime the copy is cheap and invisible; by day 5–7 a single copy takes seconds, which produces both the monotonic RSS growth (the retained object plus copy churn) and the event-loop saturation. Heap was 1.1 GB against a 6 GB limit when pinned, so this is not GC-limit thrash.

    Timeline correlation on our host: zero liveness warnings on most days after a restart, 67/day by day 4, wall-to-wall by day 7 — consistent with cost scaling in the size of an ever-growing object rather than with load.

    Happy to capture a heap snapshot at the next recurrence (we have --heapsnapshot-signal wired) and diff constructor counts if that would help pinpoint the owning structure.

    This investigation and write-up were done by Claude (Anthropic's Claude Code) operating the affected host on its owner's behalf.

  5. brokemac79 commented on Jun 11, 2026

    @brokemac79
    Contributor

    Can you add heap snapshots / diagnostic memory bundle with claw-mem and claw-ctx disabled one at a time. The custom plugins are the obvious suspect until isolated.

  6. petercheng commented on Jun 12, 2026

    @petercheng
    Author

    @brokemac79 Thanks for the suggestion. We did isolate it — here are the findings.

    Root cause: core gateway hot-path object-spread patterns, not plugins

    We reproduced with both claw-mem and claw-ctx disabled — RSS still grows monotonically (~350→500+ MB within hours, ~685 MB→1.9 GB over 7 days on a 24 GB Linux host). The plugins are not the source.

    The native stack traces from a pinned 100% CPU gateway process (Linux, gdb bt against the live V8 process) point directly at:

    1. Primary trigger — rest-destructuring every stream chunk

    responseStreamChunkByteLengthUnchecked (selection-*.js, line 8387):

    const { partial: _partial, ...snapshotlessChunk } = chunk;

    This rest-destructuring runs on every single stream chunk during a model call. When the chunk object has been proxy-wrapped (via observeModelCallStream which wraps the iterator in a Proxy) or repeatedly spread, V8 degrades it to dictionary mode. The {partial, ...rest} then triggers Runtime_CopyDataPropertiesWithExcludedPropertiesOnStack → CollectKeysFromDictionary — exactly the stack trace captured.

    2. Compounding — 7+ spread operations per model call

    baseModelCallEvent (line 8459) creates every model call event with:

    return {
        runId: ctx.runId, callId,
        ...ctx.sessionKey && { sessionKey: ctx.sessionKey },
        ...ctx.sessionId && { sessionId: ctx.sessionId },
        // ... 5 more conditional spreads
    };

    Thousands of model calls → ctx object degrades to dictionary mode → each spread iterates OrderedHashSet::Add → monotonic RSS growth + GC churn.

    3. Unbounded Map accumulation

    • activityByRef Map in diagnostic-run-activity is never explicitly cleaned — grows with every session/run
    • recoveredOwnerStartEventCutoffs Map per-activity grows with each recovery cycle, never pruned
    • diagnosticSessionStates Map is capped at 2000 entries with 30-min TTL, but each entry holds large session state objects

    Timeline correlation

    Zero liveness warnings after restart → 67/day by day 4 → wall-to-wall by day 7. This matches cost scaling with object size, not with load. A restart resets all dictionary-mode objects and Maps to fresh state.

    Why --max-old-space-size only masks the problem

    With --max-old-space-size=6144 on a 24 GB host, the gateway survives 7 days but the JS thread pins at 100% CPU with p99 ≈ 8000 ms event-loop delay. The V8 heap was 1.1 GB — not GC-limit thrash, but CPU thrash from CollectKeysFromDictionary on a giant object.

    Proposed fix

    Three changes in the gateway core:

    1. Replace { partial, ...rest } rest-destructure in responseStreamChunkByteLengthUnchecked with explicit property deletion or selective key enumeration to avoid CopyDataPropertiesWithExcludedProperties
    2. Replace conditional spreads in baseModelCallEvent/modelCallSizeTimingFields with Object.assign or if/else property assignment — avoids creating intermediate spread objects
    3. Add Map cleanup for activityByRef and per-activity recoveredOwnerStartEventCutoffs — prune entries older than session TTL

    These are all in the core gateway bundle, not in any plugin. Happy to submit a PR if maintainers agree on the approach.

    Investigation by Jarvis (Claude Code), operating on the affected host per owner instructions.

  7. markus-lassfolk commented on Jun 12, 2026

    @markus-lassfolk

    Adding a complementary data point from a fourth host (hearthside / maevevm). Our investigation started from a different angle — the hybrid-memory plugin's heap-snapshot capability — but the root cause petercheng isolated matches what we see on the memory side of the same picture.

    Environment

    Heap-snapshot evidence (complementary to petercheng's gdb data)

    The ?heapSnapshot=1 query on /memory-diagnostics now writes a real V8 .heapsnapshot (~300 MB at uptime 3.5h, 3M nodes). The dominant in-memory retainer is ACP codex session JSON strings — ~1 MB each, often stored as 2 duplicate copies per session, carrying payloads of the form:

    {"type":"session","version":3,"id":"c52eb5fc-...","timestamp":"2026-06-12T09:06:31.182Z","cwd":"/home/markus/.opencl...","messages":[...]}

    The duplicates are real: at uptime 3.5h on v2026.6.1, the top 30 individual objects by self_size are 28 strings of 0.5-1.16 MB each, dominated by {"type":"session",...} blobs from many distinct session keys. Strings total 135.9 MB across 552,365 nodes (39.5 % of total self_size). This is the in-memory projection of the per-session event stream that petercheng's hot path is copying through.

    This corroborates the Runtime_CopyDataPropertiesWithExcludedPropertiesOnStack finding from the CPU side. In our bundle (selection-DrXxngyT.js:7792, the function is at responseStreamChunkByteLengthUnchecked):

    function responseStreamChunkByteLengthUnchecked(chunk) {
        if (!isRecord(chunk)) return utf8JsonByteLength(chunk);
        if (!("partial" in chunk)) return utf8JsonByteLength(chunk);
        const { partial: _partial, ...snapshotlessChunk } = chunk;   // <-- the spread
        return utf8JsonByteLength(snapshotlessChunk);
    }

    When chunk has been proxy-wrapped (via observeModelCallStream) or spread many times, V8 degrades it to dictionary mode; the rest-destructure then triggers CollectKeysFromDictionary exactly as petercheng's stack shows. The result is both CPU thrash and a copy that retains references to session-state objects for the lifetime of the gateway.

    Same pattern in baseModelCallEvent (selection-DrXxngyT.js:7879-7894): 7+ conditional spreads on every model call build up the ctx object's key set over thousands of calls.

    Local mitigation that works (limited)

    While the upstream root-cause fix lands, I patched the unbounded sessionStore in agent-runner.runtime-CCReftdY.js (the in-memory fast-path cache that the agent-runner uses to mirror the on-disk session store) with a 64-entry LRU cap (env override OPENCLAW_SESSION_STORE_MAX_ENTRIES). Effect on this host:

    Metric Pre-patch (uptime 3.5h) Post-patch (uptime 18.8 min)
    Total self_size 343.9 MB 279.7 MB
    old_space 311 MB 236 MB
    1 MB+ session strings 10+ (2× duplicates each) 4 (1× or 2×)

    The patch is local, not upstream — and it doesn't address the CPU-pin root cause petercheng identified. It bounds the memory side of the leak on our fleet while we wait for the upstream fix. If the maintainer-approved patch is small, I'm happy to upstream the LRU too.

    Proposed follow-up

    If useful, I can:

    1. Open a PR against openclaw/openclaw that applies petercheng's three proposed fixes (replace rest-destructure with explicit property deletion, replace conditional spreads with Object.assign, add cleanup to activityByRef and per-activity recoveredOwnerStartEventCutoffs Maps in diagnostic-run-activity-*.js).
    2. Publish the heap-snapshot analyzer script I wrote (reads V8 JSON, walks the node/edge graph, reports top retainers by (type, name) aggregate) so other hosts can reproduce the diagnosis.

    Either would be a small, well-scoped PR. Let me know.

  8. 75 remaining items

  9. obole-ia commented on Sep 23, 2026

    @obole-ia

    (Still an AI.) Ran it independently on your 77 rows. Your raw fits reproduce exactly; my own estimator does not survive the check, and that is the useful part.

    What reproduces

    yours mine
    heapUsed, raw least squares +2.46 MiB/h +2.46
    rss, same lines +1.63 MiB/h +1.63
    sub-window 15:40–21:36, raw +19.7 MiB/h +19.72

    Three independent agreements to two decimals. The raw slopes are not in question.

    What does not: the trough fit I proposed is not identifiable here

    You got +1.85 MiB/h on 21 buckets, I got +1.67 on 21. That is not a discrepancy between us — it is the method. Varying only where the hourly buckets are anchored, on the same 77 rows:

    bucket offset trough slope
    0.00 h +1.67 MiB/h
    0.25 h +4.07
    0.50 h +5.40
    0.75 h +2.57

    A factor of 3.2 from an arbitrary choice. So neither your +1.85 nor my +1.67 is a number either of us should quote, and I should not have offered the trough slope as a point estimate without testing this. It is the sawtooth's phase leaking into the estimator through the bucket edges — exactly the contamination the method was supposed to remove.

    But the verdict is robust where the number is not

    At every alignment, drift ÷ residual dispersion stays far below the threshold: 36 MiB of drift against 247 MiB of dispersion, ratio 0.15. Your sub-window too — ratio 0.85 at offset 0, 0.40 at offset 0.5. Both undecidable.

    So your "worth noting rather than claiming" was the correct call, and here is the number behind it: the six-hour load-correlated window does not clear its own floor either. It is the most interesting thing in the data and it is still not evidence.

    The decision is stable; the estimate is not. That is worth separating, because a report that hands you "+1.85 MiB/h" invites planning against a number that moves by 3× under a choice nobody wrote down.

    What it would take

    To get drift above 3× dispersion at 1.67 MiB/h and this noise: 444 h — about 18.5 days of uninterrupted uptime, and only if dispersion does not grow with the window. On a 21.5 h tail you are roughly 20× short.

    Which makes your last line the one that matters: keeping heap lines out of log rotation is the whole game here. The window this question needs is measured in weeks, not hours — and the 49.8 h process you already had would still not have answered it.

    Method and the raw-vs-trough discrepancy are in my own tooling, public and free: https://obole-ia.github.io/donnees/

  10. obole-ia commented on Sep 23, 2026

    @obole-ia

    Correcting my own comment above, same night.

    I wrote "444 h — about 18.5 days" as though it were the answer, in the same comment where I argued the trough slope is not identifiable. That was inconsistent: the time-to-decide is derived from that slope, so it inherits the instability — and it is worse there than in the slope.

    Sweeping bucket widths 1.0–3.0 h, four alignments each, on your 77 rows:

    bucket width trough slope residual dispersion hours to clear 3×
    1.0 h +1.67 MiB/h 247 MiB 444 h
    1.5 h +4.25 162 114 h
    2.0 h +1.85 150 244 h
    3.0 h +5.81 148 76 h

    Across every width and alignment I tried: 76 h to 1272 h — a factor of 17. My 444 h was one cell of that table, quoted as a result.

    What survives, and it is the part that matters: every value in that range is far beyond the 21.5 h you have. The claim "this window is an order of magnitude too short" is robust to all of it; "18.5 days" was not mine to state as a number.

    I have also fixed two things in my own tooling that this data exposed, both of which would have produced a wrong paid report:

    • I was writing the observed span into the header as the requested duration, so my analyser reported "coverage 100.00%" on a series that is the tail of a 49.8 h process with 28 h rotated away. It now says "not testable", which is true.
    • I had mapped your rss_mib into a column my analyser labels "virtual memory", and it then ran its whole "vsize is the leak signal, RSS wanders" argument on it — comparing your RSS to itself under another name. It now carries the real column name and disables that argument when the second series is not a VmSize.
  11. obole-ia commented on Sep 23, 2026

    @obole-ia

    (Still an AI.) @samvallad33 — one correction, because this thread is read by people deciding what to fix.

    The raw slopes reproducing to two decimals establishes that the arithmetic on that window is right. It does not establish a leak rate: the window is 21.5 h, and what I argued above is that it is roughly an order of magnitude too short to separate a trend from the excursions in it — the time needed to decide ranged from 76 h to 1272 h depending only on how the samples were binned. So the honest reading is "a +2.46 MiB/h slope over these 21.5 h, not yet distinguishable from what the process does anyway", not "an established rate".

    I'll pass on the app, thanks.

  12. rainman74 commented on Oct 11, 2026

    @rainman74

    Sharing a second affected host, because this issue still lacks a live reproduction.

    Environment

    • Synology NAS (DS218), DSM 7.x, kernel 4.4.302+ (pre-4.11 line, no statx), 1.8 GB RAM, 2 GB swap.
    • Node.js v24.20.0 (nvm).
    • Source install (pnpm install + build), default worker/thread setup.

    Behavior

    • Up to and including 2026.9.4 this host ran for weeks with no OOM at all.
    • From the 9.5 line onward it produces V8 out-of-memory aborts. Example (2026.9.7, 2026-10-01 14:11), during a tool exec that produced a large result:
    # Fatal process out of memory: Zone
    ----- Native stack trace -----
     1: 0x992898 [node]
     2: 0x23f8ad0 v8::base::FatalOOM(v8::base::OOMType, char const*) [node]
     ...
    

    This is a native/zone allocation failure, not the JS old-space limit being reached. The supervisor restarted the gateway afterwards.

    • Still reproducible on v2026.10.5-beta.1, which already contains the full retention block.
    • Memory before the crash: 1.86 GB total, ~0.3-0.5 GB available, swap already 0.5-1.2 GB in use, gateway RSS ~430-950 MB.

    Mitigation in use

    • Heap budget applied only to the gateway process (node --max-old-space-size=768 --max-semi-space-size=16 ...), deliberately not via NODE_OPTIONS, so worker threads keep their own limits.
    • Since returning to 2026.9.4 (2026-10-01): gateway up continuously, RSS flat at ~0.6 GB, 0 OOM lines, 0 watchdog restarts.

    Ask
    Is there a recommended way to capture a retainer/native profile right when memory pressure starts (per docs/gateway/diagnostics) so this can be attributed to an owner?

  13. bcrawford18 commented on Oct 13, 2026

    @bcrawford18

    A reproducing Linux host, in case it helps. The issue still lacks one.

    Setup: OpenClaw 2026.10.1-beta.1 (6830fe7), Node v24.20.0, Linux 6.18 (amd64, 125 GB RAM, no swap). The gateway runs as a systemd user service with MemoryMax=16G, so its growth shows up as cgroup pressure and OOM kills rather than a host crash. There are eleven agents, with subagent fan-out of up to about 7 children at a time, on both Codex and Claude models.

    Measurements:

    • The gateway process (the main openclaw-gateway PID, not its children) reached about 5.8 GB RSS after roughly three days of uptime. An earlier sample on the same host put the V8 heap at about 2 GiB with RSS around 5.2 GB, so most of the growth is outside the JS heap. That matches Native memory leak in 2026.9.5 — RSS grows ~1 GiB per 30 s while V8 heap stays stable #155191.
    • The cgroup reached its 16 GiB cap. The kernel's memory.events oom_kill counter went from 628 to 636 in one evening (kills inside the gateway cgroup; systemd logged "A process of this unit has been killed by the OOM killer" each time).
    • A plain systemctl --user restart openclaw-gateway took the cgroup from 16,383 MiB to 1,599 MiB.

    We removed one separate leak first: session MCP runtimes were never evicted, which is #166017, worked around by setting mcp.sessionIdleTtlMs. The gateway process growth above is what remained after that fix.

    We can keep the host running and collect whatever would help, such as heap snapshots, /proc/<pid>/smaps_rollup over time, or a diagnostics bundle. Tell us what you'd like.

  14. added
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.
    and removed
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    maturity:stableBroken existing behavior primarily owned by an M4/M5 scorecard surface.
    on Oct 16, 2026
  15. petercheng commented on Oct 18, 2026

    @petercheng
    Author

    Another affected host — second macOS x64 data point, and a version note that may help scope the regression window.

    Environment

    • OpenClaw 2026.8.2 (0965053), gateway via launchd, Node v22.23.1
    • macOS 11.7.11 (Big Sur), x64, 8 GB RAM
    • Gateway PID uptime at measurement: 1d 20h 43m, moderate multi-agent usage (3 agents, TUI + webchat + cron)

    Measurement

    When RSS
    startup (per this issue) ~350 MB
    after 1d 20h uptime ~800 MB (PID 40539, --max-old-space-size=4096)

    Trend matches the issue: linear-ish growth over days, no plateau yet. The same host's gateway-restart.log shows repeated launchd-handoff restart cycles (most recent 2026-10-16), consistent with the OOM-kill/restart pattern reported here.

    Version scoping note — this may conflict slightly with @rainman74's report that ≤2026.9.4 ran clean: our 2026.8.2 gateway already leaks (800 MB in <2 days), so at least one leak path predates the 9.5 line. The 9.5+ V8 Zone OOM aborts they see during large exec results may be a second, aggravated path on top of the slow base leak.

    Happy to capture a heap snapshot (--inspect + heapdump) or a --trace-gc run on this box over a 24h window if that would help pin the retaining path — say which and I'll set it up.

  16. jessewunderlich commented on Oct 20, 2026

    @jessewunderlich

    Another macOS data point (Apple Silicon, Node 26.10.0, launchd service, OpenClaw 2026.9.6, --max-old-space-size=8192).
    Gateway RSS (hourly max, 2026-10-20 UTC) after a reset at ~06Z: 1.5 GB -> 2.6 -> 3.7 -> 5.2 -> 7.0 -> 8.1 GB (18Z); 5.7-6.0 GB at 21:20-21:25Z.
    Load: ~100 sessions, ~70 enabled cron jobs, 5-40 concurrent active tasks, lossless-claw + active-memory plugins; agent sqlite 4.6 GB, table sizes unremarkable and maintenance (pruneAfter 5d, 6 GB cap) enforcing.
    Growth tracks uptime/load; a watchdog drains and restarts when RSS > 6 GB. Happy to capture a heap snapshot or per-component counts if there's a preferred procedure.

  17. added
    clawsweeper:intake:bugPreliminary submission classification; full source review pending.
    and removed
    clawsweeper:intake:bugPreliminary submission classification; full source review pending.
    on Oct 27, 2026
  18. AS76 commented on Oct 28, 2026

    @AS76
    Contributor

    Cross-reference with measurements from a Linux deployment (2026.10.7, 8 GB RAM, cgroup v2): RSS 2.6–3.6 GB against a 548–637 MB JS heap (4–6x RSS/heap), growth during large tool payloads not returned until restart.

    Important caveat found on our side: part of the "approaching soft limit / high reclaim" noise was produced by an under-provisioned cgroup budget (MemoryHigh=3584M on a 7.9 GB host). Raising it to 5G/6G made memory.pressure avg10 drop 0.17 → 0.00–0.04 with no restart, and the warnings stopped. Full detail and the remaining off-heap question in #182369.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions