Repository navigation
Open
Description
What we need
Deterministic tests proving Dev Proxy doesn't retain memory across (a) many proxied requests and (b) repeated hot reloads.
Problem and who it's for
- Users run Dev Proxy for hours during development and in CI; leaks show up as growing memory and eventually slowdowns or crashes. Several open PRs address exactly this: Switch Dev Proxy to Workstation GC to reduce memory use #2150 (GC mode), Print and release buffered request logs on failed and cancelled requests #2151 (buffered request logs), Cache schema validation and load plugin data files from a stream #2152, Stop hot reload from retaining every previous generation #2153 (hot reload retaining every previous generation), Reduce per-request body copies and mock serving costs #2154 (per-request body copies).
- Maintainers currently have no way to verify those claims or catch regressions. A timing/throughput gate would be too noisy on CI runners; retained-memory checks are deterministic.
How to implement
In DevProxy.Integration.Tests, using the existing in-process harness (KestrelProxyHarness / PluginTestHost, FakeOrigin):
- Hot reload retention: start the proxy with a config, trigger N (e.g. 20) hot reloads by rewriting the config file. Hold
WeakReferences to each previous generation's root objects (plugin instances / per-generation service provider). AfterGC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect();, assert all previous generations are collected. This is exact rather than threshold-based. - Per-request retention: warm up with ~1k requests (mocked via
MockResponsePluginand passthrough toFakeOrigin, including large bodies and a cancelled/failed request), takeGC.GetTotalMemory(forceFullCollection: true), send ~10k more, measure again, assert growth below a small bound (e.g. a few MB). Also assert per-request objects (e.g. session/log buffers) are collected viaWeakReferencewhere we can reach them. - Keep runtime under ~1 minute; run in the integration test job. Mark as non-parallel if needed (
TestParallelization).
Done when
- The hot-reload test fails on
mainbefore Stop hot reload from retaining every previous generation #2153 (if the retention reproduces) and passes with Stop hot reload from retaining every previous generation #2153. If it doesn't reproduce onmain, the test is proven by step below instead. - Introducing a deliberate leak (a test plugin appending each request or generation to a static list) makes the relevant test fail.
- Stable across repeated runs on Linux, macOS and Windows CI (no flakes over, say, 10 runs).
- Each test reports what it measured (generations checked, requests sent, bytes retained).
Metadata
Metadata
Assignees
Labels
No labels
Activity