diff --git a/src/mcp/mcp.c b/src/mcp/mcp.c index 36afeb6f8..3785f5f87 100644 --- a/src/mcp/mcp.c +++ b/src/mcp/mcp.c @@ -10419,6 +10419,13 @@ static void release_request_store(cbm_mcp_server_t *srv) { srv->store = NULL; free(srv->current_project); srv->current_project = NULL; + /* The close above frees a connection's worth of page cache. Ask the + * allocator to hand those pages back now, which keeps a long-lived daemon + * flat across thousands of request-scoped stores (#581). This only became + * meaningful once the Windows interposer made the pages mimalloc's: an + * earlier attempt aimed at the CRT heap instead and could not release + * them. POSIX already purges on free, so this is a no-op there. */ + cbm_mem_collect(); } char *cbm_mcp_handle_tool(cbm_mcp_server_t *srv, const char *tool_name, const char *args_json) {