-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
Gateway memory leak: 389MB → 14.7GB over 4 days with session accumulation #54155
Copy link
Copy link
Open
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Description
The
openclaw-gatewayprocess leaks memory steadily over multi-day uptime, growing from ~389MB at startup to 14.7GB (58% of 24GB RAM on Mac Mini) after approximately 4 days of continuous operation.Environment
codingObserved behavior
compaction.mode: "safeguard"withmaxHistoryShare: 0.5and 131K context window means sessions can accumulate ~65K tokens before compaction triggerscache-ttl, TTL 6h) does not appear to reclaim in-process memory after pruningLikely contributing factors
structuredClonein session store cache may be related (see perf: structuredClone in session store cache causes native memory leak (~1GB/min) #45438)seqByRunMap growth (see Memory leak: seqByRun Map in agent-events.ts grows unbounded #51819) may compound thisSteps to reproduce
ps aux | grep openclaw-gateway | awk '{print $6/1024 "MB"}'Workaround
We implemented a daily maintenance LaunchAgent that:
.reset.*files > 3 daysmaxHistoryShare: 0.3, pruning TTL2h,keepLastAssistants: 2This keeps memory under control but doesn't fix the underlying leak.
Expected behavior
Gateway RSS should plateau or return memory after session compaction/pruning, not grow unboundedly. Completed subagent sessions should be evicted from memory.