The image MCP server kept every drawing, and every video, in memory for an
hour (up to 256 MB), and swept them only when another image arrived. A
drawing also held its reply, the base64 strings parsed from it and the decoded
bytes at once. Now:
- imageMCPKeepFile writes the image to <config>/image-mcp (emptied at the
first use in a run) and the file URL serves it from there; only the
metadata is in memory. A timer removes it at its hour. If it can't be
written the bytes stay in memory, as before.
- imageMCPDrawn drops the recorded reply and each b64 string as it is decoded;
the stdio server (internal/imagemcp) clears each b64 once decoded.
- both hand the heap back (debug.FreeOSMemory) when a drawing is done: the
Go scavenger gives it back slowly, and Task Manager showed it as
magpie's.
The foreground/background numbers in the report (WebView2 processes a few MB
when hidden) are WebView2 suspending, not a leak.
Run: TestImageMCPKeepsDrawingsOffTheHeap (new; 6 x 12 MB drawings kept):
heap +71 MB on the old code, +0 after. internal/imagemcp and the gateway's
Image/Video/MCP/Browser/Record tests, gofmt, and vet for darwin, linux
and windows on mote. Broke it by hand: the old image_mcp.go with the new
test is red. Not run: the full suite, a real vendor's drawing, Windows.