Skip to content

fix(devserver): memory-conscious GC profile for the Hot Reload host (backport #24209) - #24415

Merged
agneszitte merged 1 commit into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24209
Sep 11, 2026
Merged

agneszitte merged 1 commit into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24209

Conversation

@mergify

@mergify mergify Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #24203

PR Type:

🐞 Bugfix

What changed? 🚀

The Hot Reload dev-server host (Uno.UI.RemoteControl.Host) is a long-running background daemon on the developer's machine, but it inherited the Microsoft.NET.Sdk.Web default GC profile (Server GC), which is throughput-oriented and holds onto committed memory. Under Hot Reload each emit allocates a large amount of transient garbage (tens of MB on a real app, for a ~150 KB delta); with Server GC the runtime feels no pressure to collect it, so the host's working set climbs monotonically into the multi-GB range over a working session (see #24203 / #24151).

This aligns the host's GC profile with a memory-conscious background daemon:

  • ServerGarbageCollection=false + ConcurrentGarbageCollection=true → Workstation background GC: pressure is applied early, so the transient garbage is actually collected and the working set stays bounded.
  • New runtimeconfig.template.json:
    • System.GC.ConserveMemory=5 → keeps the heap compact and decommits freed memory back to the OS (so RSS actually goes down, not just the managed heap).
    • System.GC.HeapHardLimitPercent=66 → relative last-resort ceiling (no absolute, machine-dependent value to pick).
    • System.GC.HighMemoryPercent=70 → the GC becomes aggressive earlier when the machine is under memory pressure — a good citizen on a shared dev box.

Measured (synthetic LOH churn, 40 iterations, ~27 MB live heap in all three cases) — peak / final process working set:

GC profile RSS peak RSS final
Server GC (previous default) 670 MB 534 MB
Workstation GC 387 MB 387 MB
Workstation + ConserveMemory 317 MB 317 MB (flat)

The emitted runtimeconfig.json was verified to contain the five expected System.GC.* values.

This is the fast, low-risk mitigation track. The root-cause tracks (non-incremental generators, connection/workspace lifetime, per-solution/baseline/target workspace sharing) are tracked separately in #24204, #24205, #24206 and #24207.

PR Checklist ✅

  • 🧪 Added [Runtime tests, UI tests, or a manual test sample] — N/A: runtime GC configuration only; validated by measured working-set behavior and the emitted runtimeconfig.json.
  • 📚 Docs have been added/updated following the documentation template — N/A.
  • 🖼️ Validated PR Screenshots Compare Test Run results — N/A (no UI change).
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

This is an automatic backport of pull request #24209 done by [Mergify](https://mergify.com).

The dev-server host is a long-running background daemon on the developer's
machine, but inherited the Microsoft.NET.Sdk.Web default (Server GC), which is
throughput-oriented and retains committed memory. Under Hot Reload each emit
allocates tens of MB of transient garbage; Server GC feels no pressure to
collect it, so RSS climbs into multi-GB over a session.

Align the host GC profile with a memory-conscious background daemon:
- ServerGarbageCollection=false + ConcurrentGarbageCollection=true (Workstation
  background GC: pressure applied early, transient garbage collected).
- runtimeconfig.template.json: System.GC.ConserveMemory=5 (compact heap +
  decommit to OS), HeapHardLimitPercent=66 (relative last-resort ceiling),
  HighMemoryPercent=70 (react earlier under machine memory pressure).

Fixes #24203

(cherry picked from commit 26bcadf)

@dr1rrb dr1rrb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backport approved — straight mergify backport of an already-approved master fix.

@agneszitte agneszitte added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 4, 2026
@agneszitte
agneszitte merged commit 10d1174 into release/stable/6.7 Sep 11, 2026
13 checks passed
@agneszitte
agneszitte deleted the mergify/bp/release/stable/6.7/pr-24209 branch September 11, 2026 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants