Skip to content

Memory leak: process grows to 50+ GB virtual memory over hours/days, crashes Windows #581

Description

@baoyu0

Description

codebase-memory-mcp v0.8.1 has a severe memory leak when running as a persistent MCP server (stdio mode). Over the course of hours to ~2 days, the process grows to consume 50+ GB of virtual memory, eventually exceeding the system commit limit and crashing the entire Windows machine.

Environment

  • OS: Windows 10, 64-bit (build 10.0.26100)
  • codebase-memory-mcp version: v0.8.1 (installed via the official Windows .zip release, 269 MB binary)
  • RAM: 32 GB physical
  • Page file: system-managed
  • Agent: Hermes Agent (launches codebase-memory-mcp as a subprocess via MCP stdio config)
  • Single project indexed: C:/Users/zhaid/.pi/agent (~55k nodes, ~113k edges, ~97 MB on disk)
  • Config: auto_index=false, auto_index_limit=50000

Evidence

Windows Resource-Exhaustion-Detector (Event ID 2004) logged twice before the crash:

00:23:54 — 8 minutes before crash:

Process Virtual Memory (Commit Charge)
codebase-memory-mcp.exe (PID 52508) 46.4 GB
python.exe (Hermes companion) 59.4 GB

00:28:53 — 3 minutes before crash — still growing:

Process Virtual Memory
codebase-memory-mcp.exe (PID 52508) 54.5 GB (+8 GB in 5 min)
python.exe (Hermes companion) 59.3 GB

Combined commit of ~114 GB exceeded the system commit limit (~100 GB = 32 GB RAM + page file), triggering:

  • Volsnap event 6: "The shadow copy of volume C: could not create a new page stack. The system may be low on virtual memory."
  • OmenCommandCenterBackground.exe crashed with System.OutOfMemoryException
  • Everything.exe crashed with stack overflow (0xc00000fd)
  • dwm.exe (Desktop Window Manager) crashed 3 times
  • AUDIODG.EXE (audio) crashed
  • Eventually Kernel-Power 41: system rebooted uncleanly

Recurrence

This has happened at least 3 times since installation (June 12):

  • Jun 13: same pattern — the process consumed ~107 GB
  • Jun 15: ~99 GB
  • Jun 23: ~114 GB (the crash described above)

Comparison vs normal state

Right now after a fresh restart:

codebase-memory-mcp.exe   PID=22416  WS=12.3 MB

Working set is 12 MB. The commit charge grows to 50+ GB over time, which is clearly a memory leak in a long-running data structure.

Suspected cause

The knowledge graph data structure (nodes, edges, PageRank scores, etc.) is being retained in process memory without eviction as the index accumulates queries and incremental updates. The on-disk index is only ~97 MB, indicating the in-memory representation is leaking by multiple orders of magnitude.

Steps to reproduce

  1. Run codebase-memory-mcp in stdio MCP server mode (as Hermes/Claude Code Agent would)
  2. Let it run for several hours to 2 days while the agent queries it
  3. Monitor virtual memory usage — it will climb steadily and never decrease
  4. Eventually the system runs out of commit charge and crashes

Note: auto_index=false does not prevent the leak — the growth happens on query/read operations, not just indexing.

Request

Please investigate the in-memory graph cache and query result retention. Consider:

  • Adding an LRU eviction policy for cached query results
  • Streaming graph data instead of keeping the full index in RAM
  • A configurable max-memory limit that triggers compaction/eviction

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstability/performanceServer crashes, OOM, hangs, high CPU/memorywindowsWindows-specific issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions