Skip to content

Memory not released after indexing: 20GB+ RSS for 5MB of indexed data #832

Description

@fxfxfx123

Summary

After indexing a small project (65 files, 1.3MB, 2509 nodes), codebase-memory-mcp retains 20GB+ RSS on a 32GB Windows machine. Memory grows monotonically and is never released to the OS.

Environment

  • OS: Windows 11, i7-12700 (20 cores), 32GB RAM
  • CBM Version: 0.8.1
  • Project: 65 Markdown files, 1.3MB, 2509 nodes

Root Cause (from source code)

  1. mimalloc abandoned-thread arenas not purged (mem.c missing mi_option_abandoned_thread_purge)
  2. Default worker count uses all 20 cores, each with its own mimalloc arena
  3. DEFAULT_RAM_FRACTION=0.5 means 16GB budget, no pressure to release

Observed memory

Without fix: 20GB+ RSS, growing 600MB/min, never releases
With workaround (CBM_WORKERS=1): 13MB stable

Fix

PR #831: #831

  • Enable mi_option_abandoned_thread_purge in mem.c
  • Lower DEFAULT_RAM_FRACTION from 0.5 to 0.25
  • Cap initial worker count at 8 in system_info.c

Workaround

Set CBM_WORKERS=1 in MCP env config and run: codebase-memory-mcp config set auto_index false

Activity

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

    bugSomething isn't workingpriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.stability/performanceServer crashes, OOM, hangs, high CPU/memorywindowsWindows-specific issues

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions