From 063d3126982c400a30881d80e65885c40c2fb7b2 Mon Sep 17 00:00:00 2001 From: Martin Vogel Date: Sat, 25 Jul 2026 15:07:00 +0200 Subject: [PATCH] wip: collect at store release now that pages are mimalloc's Signed-off-by: Martin Vogel --- src/mcp/mcp.c | 7 +++++++ 1 file changed, 7 insertions(+) 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) {