mirror of
https://github.com/wolfpld/tracy.git
synced 2026-07-23 14:39:14 +00:00
tracy_mcp.py runs as a long-lived singleton shared across every MCP client, and the `instances` dict never evicted entries — each live_connect/load_capture materializes a full trace (zones, messages, callstacks, memory events) with no size cap, so private bytes grow without bound across recording sessions unless unload_capture is called manually every time. Add two backstops, both env-configurable: an LRU cap (TRACY_MCP_MAX_INSTANCES, default 4) enforced on live_connect/ load_capture that never evicts a still-connected live instance, and a periodic sweep that drops a disconnected live instance once it has sat idle past TRACY_MCP_DISCONNECTED_TTL_S (default 1800s), keeping a grace window for post-session analysis. list_instances now reports connected/idle_seconds so callers can spot stale sessions, and unload_capture/eviction now explicitly call Worker.shutdown() instead of relying on GC. Document the lifecycle expectations (call unload_capture proactively; treat eviction as a backstop) in eval_guide.md.