Repository navigation
fix: prevent .NET 10 COM wrapper memory leak in production - #1215
Conversation
Work around dotnet/runtime#129191 for Release production builds while preserving managed debugger support in Debug and explicit DevBuild builds. Co-authored-by: Copilot <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 7:42 PM ET / 23:42 UTC. ClawSweeper reviewWhat this changesThis PR emits a .NET runtime configuration switch only for non-development Release tray builds, with a build-matrix test for Release, Debug, DevBuild, and MSIX variants. Regression provenancePossible regression — suspected (failure trace). No predecessor PR is attributed. Merge readinessKeep open for a maintainer decision on the intentional production-debugging tradeoff. The narrowly scoped runtime switch, matrix test, and clean three-way merge support the implementation; likely related people: @shanselman (high confidence). Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togetherThe WinUI tray project converts build properties into the runtime configuration consumed by the Companion application. This change decides whether production startup disables a .NET diagnostics feature implicated in COM-wrapper memory retention. flowchart LR
A[Build configuration] --> C[Tray project]
B[DevBuild setting] --> C
C --> D{Release and non-dev?}
D -->|Yes| E[Disable debugger diagnostics]
D -->|No| F[Retain debugger diagnostics]
E --> G[Companion runtime]
F --> G
Decision needed
Why: This is an intentional compatibility and operational-debugging tradeoff, not a mechanical correctness question that source review can decide. Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the scoped workaround only after a maintainer explicitly accepts the temporary Release-debugging limitation, then revisit or remove it when the upstream .NET runtime regression is fixed. Do we have a high-confidence way to reproduce the issue? No. The PR documents a heap trace and proves generated configuration behavior, but it does not provide a repeatable current-head COM-wrapper retention reproduction. Is this the best way to solve the issue? Yes for the stated temporary mitigation. The project-level condition covers Release packaging variants while preserving the intended Debug and DevBuild diagnostic paths. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8ff0353919cf. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Co-authored-by: Copilot App <[email protected]>
Summary
System.Diagnostics.Debugger.IsSupportedonly for non-dev Release buildsDevBuild=truebuildsWhy
A live OpenClaw Companion process reached about 13.5 GB private memory. Heap analysis found 13.76 GB retained by duplicate
System.Runtime.InteropServices.ComWrappers+ManagedObjectWrapperHolder[]entries, including two 4 GB arrays rooted throughChatPageandReactorHostControl.This matches the open .NET 10 runtime regression dotnet/runtime#129191. The runtime's diagnostics-only CCW registry appends duplicate wrapper references on every managed-to-native crossing. Setting
System.Diagnostics.Debugger.IsSupported=falsebypasses that registry. This PR scopes the workaround to production Release artifacts so local debugging remains available.Validation
./build.ps1dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restoredotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restoregpt-5.6-sol, high reasoningReal behavior proof
Generated
OpenClaw.Tray.WinUI.runtimeconfig.jsonandapp-identity.txtfrom current-head ARM64 builds:System.Diagnostics.Debugger.IsSupportedfalseThis is a build/runtime configuration change with no user-visible UI state, so screenshot proof is not applicable.