Skip to content

fix(memory): prevent unmanaged Bitmap, HttpClient handler, JsonSerializerOptions, and MCP session leaks - #105

Merged
spelech merged 1 commit into
mainfrom
fix/unmanaged-bitmap-http-and-mcp-leaks
Nov 1, 2026
Merged

spelech merged 1 commit into
mainfrom
fix/unmanaged-bitmap-http-and-mcp-leaks

Conversation

@spelech

@spelech spelech commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Cache Bitmap instances per �yte[] via ConditionalWeakTable<byte[], Bitmap> in ImageSourceConverter and use static SolidColorBrush instances in StageStatusBrushConverter to eliminate native SkiaSharp and brush allocations on repeated bindings.
  • Share a static HttpMessageHandler (SocketsHttpHandler with 2-minute PooledConnectionLifetime on non-browser platforms) with disposeHandler: false in HttpHelper.CreateClient.
  • Deterministically dispose HttpResponseMessage, HttpContent, and HttpClient instances across TelemetryService, OllamaModelService, SettingsViewModel, AudioStudioViewModel, and AiAppTools.
  • Reuse the static JsonSerializerOptions (JsonOptions) across AiAppTools methods to prevent reflection metadata cache leaks.
  • Enable options.Stateless = true on AddMcpServer().WithHttpTransport(...) and track /api/video, /api/3d, and /api/audio activity in Program.cs.

@spelech
spelech force-pushed the fix/unmanaged-bitmap-http-and-mcp-leaks branch 3 times, most recently from 3676294 to 1bfcfa6 Compare November 1, 2026 21:49
@spelech
spelech force-pushed the fix/unmanaged-bitmap-http-and-mcp-leaks branch from 1bfcfa6 to b40de71 Compare November 1, 2026 21:58
@spelech
spelech merged commit cb7a863 into main Nov 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant