Skip to content

Memory leak: seqByRun Map in agent-events.ts grows unbounded #51819

@aneym

Description

@aneym

Bug

The seqByRun Map in src/infra/agent-events.ts stores one entry per runId but never deletes them. clearAgentRunContext() cleans up runContextById but does not touch seqByRun.

Over time this Map grows by hundreds of entries per day and is never pruned, contributing to heap growth on long-running gateways.

Expected behavior

seqByRun.delete(runId) should be called in clearAgentRunContext() alongside the existing runContextById cleanup.

Environment

  • openclaw 2026.3.13
  • Node 25.8.1 (Apple Silicon)
  • Gateway running as launchd daemon, crashed with OOM after ~19 hours at 4GB heap

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions